cmacrae 10 лет назад
Родитель
Сommit
2f4b192ef4

+ 22 - 3
README.md

@@ -16,15 +16,17 @@ This role deploys a full [Sensu](https://sensuapp.org) stack, a modern, open sou
 
 ## Supported Platforms
 ### Current Release
+
 - [SmartOS - base-64 15.x.x](https://docs.joyent.com/images/smartos/base#version-15xx)
-- [Ubuntu - 15.04 (Vivid Vervet)](http://releases.ubuntu.com/15.04/)
 - [CentOS - 7](https://wiki.centos.org/Manuals/ReleaseNotes/CentOS7)
+- [Debian - 8 (Jessie)](https://wiki.debian.org/DebianJessie)
+- [Ubuntu - 15.04 (Vivid Vervet)](http://releases.ubuntu.com/15.04/)
 
 ### Future Releases
+
 - OpenBSD
 - FreeBSD
 - NetBSD
-- Debian
 
 ## Role Variables
 All variables have sensible defaults, which can be found in `defaults/main.yml`.
@@ -59,6 +61,7 @@ _Note: The above options are intended to provide users with flexibility. This al
 | `redis_host` | `"{{ groups['redis_servers'][0] }}"` | Hostname/IP address of the Redis node |
 | `redis_server` | `false` | Determines whether to include the deployment of Redis |
 | `redis_pkg_repo` | _undefined_ |  The PPA to use for installing Redis from (specific to Debian flavored systems) |
+| `redis_service_name` | redis | The name of the Redis service |
 | `redis_pkg_name` | redis |  The name of the Redis package to install |
 | `redis_pkg_state` | present | The state of the Redis package (should be set to `present` or `latest`) |
 | `redis_port` | 6379 | The transmission port for Redis communications |
@@ -114,7 +117,6 @@ sensu_ssl_server_key: "{{ dynamic_data_store }}/{{ groups['sensu_masters'][0] }}
 |--------------------|---------------|------------------------------|
 | `redis_pkg_repo`   | `'ppa:rwky/redis'` | The PPA to use for installing Redis from |
 
-
 ### [Sensu Properties](https://sensuapp.org/docs/0.21/install-sensu)
 | Name               | Default Value | Description                  |
 |--------------------|---------------|------------------------------|
@@ -125,6 +127,23 @@ sensu_ssl_server_key: "{{ dynamic_data_store }}/{{ groups['sensu_masters'][0] }}
 | `uchiwa_pkg_version` | _See `vars/Ubuntu.yml`_ | The version of the Uchiwa package to fetch (specific to Linux systems) |
 | `uchiwa_pkg_download_url`  | _See `vars/Ubuntu.yml`_ | The URL of the Uchiwa package to fetch |
 
+## Debian
+### [Redis Server Properties](https://sensuapp.org/docs/0.21/redis)
+| Name               | Default Value | Description                  |
+|--------------------|---------------|------------------------------|
+| `redis_pkg_repo`   | `'ppa:rwky/redis'` | The PPA to use for installing Redis from |
+| `redis_service_name` | redis-server | The name of the Redis service |
+
+### [Sensu Properties](https://sensuapp.org/docs/0.21/install-sensu)
+| Name               | Default Value | Description                  |
+|--------------------|---------------|------------------------------|
+| `sensu_user_name`    | root        | The name of the Sensu service user |
+| `sensu_group_name`   | root        | The name of the Sensu service user's primary group |
+| `uchiwa_pkg_download_sha256sum` | _See `vars/Debian.yml`_ | The SHA256 hash sum to use for verification of the Uchiwa package being fetched |
+| `uchiwa_pkg_download_path` | `/root/uchiwa_latest.deb` | The path to fetch the Uchiwa package to |
+| `uchiwa_pkg_version` | _See `vars/Debian.yml`_ | The version of the Uchiwa package to fetch (specific to Linux systems) |
+| `uchiwa_pkg_download_url`  | _See `vars/Debian.yml`_ | The URL of the Uchiwa package to fetch |
+
 ## CentOS
 ### [Sensu Properties](https://sensuapp.org/docs/0.21/install-sensu)
 | Name               | Default Value | Description                  |

+ 1 - 0
defaults/main.yml

@@ -18,6 +18,7 @@ rabbitmq_sensu_vhost: /sensu
 # Redis server properties
 redis_host: "{{ groups['redis_servers'][0] }}"
 redis_server: false
+redis_service_name: redis
 redis_pkg_repo: ~
 redis_pkg_name: redis
 redis_pkg_state: present

+ 2 - 2
docs/index.md

@@ -14,15 +14,15 @@ An [Ansible](https://ansible.com) role that deploys a full [Sensu](https://sensu
 ### Current Release
 
 - [SmartOS - base-64 15.x.x](https://docs.joyent.com/images/smartos/base#version-15xx)
-- [Ubuntu - 15.04 (Vivid Vervet)](http://releases.ubuntu.com/15.04/)
 - [CentOS - 7](https://wiki.centos.org/Manuals/ReleaseNotes/CentOS7)
+- [Debian - 8 (Jessie)](https://wiki.debian.org/DebianJessie)
+- [Ubuntu - 15.04 (Vivid Vervet)](http://releases.ubuntu.com/15.04/)
 
 ### Future Releases
 
 - OpenBSD
 - FreeBSD
 - NetBSD
-- Debian
 
 ## Role Variables
 All variables have sensible defaults, which can be found in `defaults/main.yml`.  

+ 17 - 0
docs/role_variables.md

@@ -95,6 +95,23 @@ sensu_ssl_server_key: "{{ dynamic_data_store }}/{{ groups['sensu_masters'][0] }}
 | `uchiwa_pkg_version` | _See `vars/Ubuntu.yml`_ | The version of the Uchiwa package to fetch (specific to Linux systems) |
 | `uchiwa_pkg_download_url`  | _See `vars/Ubuntu.yml`_ | The URL of the Uchiwa package to fetch |
 
+## Debian
+### [Redis Server Properties](https://sensuapp.org/docs/0.21/redis)
+| Name               | Default Value | Description                  |
+|--------------------|---------------|------------------------------|
+| `redis_pkg_repo`   | `'ppa:rwky/redis'` | The PPA to use for installing Redis from |
+| `redis_service_name` | redis-server | The name of the Redis service |
+
+### [Sensu Properties](https://sensuapp.org/docs/0.21/install-sensu)
+| Name               | Default Value | Description                  |
+|--------------------|---------------|------------------------------|
+| `sensu_user_name`    | root        | The name of the Sensu service user |
+| `sensu_group_name`   | root        | The name of the Sensu service user's primary group |
+| `uchiwa_pkg_download_sha256sum` | _See `vars/Debian.yml`_ | The SHA256 hash sum to use for verification of the Uchiwa package being fetched |
+| `uchiwa_pkg_download_path` | `/root/uchiwa_latest.deb` | The path to fetch the Uchiwa package to |
+| `uchiwa_pkg_version` | _See `vars/Debian.yml`_ | The version of the Uchiwa package to fetch (specific to Linux systems) |
+| `uchiwa_pkg_download_url`  | _See `vars/Debian.yml`_ | The URL of the Uchiwa package to fetch |
+
 ## CentOS
 ### [Sensu Properties](https://sensuapp.org/docs/0.21/install-sensu)
 | Name               | Default Value | Description                  |

+ 3 - 7
docs/testing.md

@@ -1,10 +1,11 @@
 # Testing
 A small testing framework is provided with this role using [Vagrant](https://vagrantup.com/).  
 
-To test this role locally, once you've set up Vagrant, simply `cd` to `tests` and run `vagrant up [ubuntu15|centos7]`, after which you can visit the following URLs in your browser for the associated deployments:  
+To test this role locally, once you've set up Vagrant, simply `cd` to `tests` and run `vagrant up [centos7|debian8|ubuntu15]`, after which you can visit the following URLs in your browser for the associated deployments:  
 
-- Ubuntu 15.04: `http://localhost:3000`
 - CentOS 7: `http://localhost:3001`
+- Debian 8: `http://localhost:3002`
+- Ubuntu 15.04: `http://localhost:3003`
 
 _Note: To test SmartOS, please simply roll out a base64 zone_  
 
@@ -22,8 +23,3 @@ It is expected that the following two handlers, triggered at the end of the test
 
 Both these handlers use the `delegate_to` directive, which does not play nice with Vagrant.  
 This __is__ expected to work in real deployments.
-
-### Malformed Vagrant inventory
-The inventory file generated by Vagrant may be prone to clashes when spinning up test VMs, as both the Ubuntu & CentOS Vagrant files have their VMs listed in the same groups.  
-This will usually be exhibited by failing tasks which require inventory fact lookups, so expect to see failures when doing index lookups against host groups.  
-A temporary workaround is to remove the inventory file generated by Vagrant: `$ rm -f .vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory`

files/ubuntu_redis_systemd.service → files/redis_systemd.service


+ 3 - 0
handlers/main.yml

@@ -3,6 +3,9 @@
   - name: restart rabbitmq service
     service: name={{ rabbitmq_service_name }} state=restarted
   
+  - name: restart redis service
+    service: name={{ redis_service_name }} state=restarted
+
   - name: restart uchiwa service
     service: name=uchiwa state=restarted
 

+ 3 - 3
meta/main.yml

@@ -102,11 +102,11 @@ galaxy_info:
   #  versions:
   #  - all
   #  - any
-  #- name: Debian
-  #  versions:
+  - name: Debian
+    versions:
   #  - all
   #  - etch
-  #  - jessie
+    - jessie
   #  - lenny
   #  - squeeze
   #  - wheezy

+ 20 - 0
tasks/Debian/dashboard.yml

@@ -0,0 +1,20 @@
+---
+# tasks/Debian/dashboard.yml: Deployment of the Uchiwa dashboard
+# Specific to Debian
+
+  - include_vars: "{{ ansible_distribution }}.yml"
+
+  - name: Retrieve the Uchiwa deb package
+    get_url:
+      url: "{{ uchiwa_pkg_download_url }}"
+      dest: "{{ uchiwa_pkg_download_path }}"
+      sha256sum: "{{ uchiwa_pkg_download_sha256sum }}"
+
+  - name: Install Uchiwa from the retrieved deb package
+    apt: deb={{ uchiwa_pkg_download_path }} 
+
+  - name: Deploy Uchiwa config
+    template:
+      src: uchiwa_config.json.j2
+      dest: "{{ sensu_config_path }}/uchiwa.json"
+    notify: restart uchiwa service

+ 19 - 0
tasks/Debian/main.yml

@@ -0,0 +1,19 @@
+---
+# tasks/Debian/main.yml: Debian specific set-up
+# This takes care of base prerequisites for Debian
+
+  - include_vars: "{{ ansible_distribution }}.yml"
+
+  - name: Ensure the Sensu APT repo GPG key is present
+    apt_key:
+      url: http://repositories.sensuapp.org/apt/pubkey.gpg
+      state: present
+
+  - name: Ensure the Sensu Core APT repo is present
+    apt_repository:
+      repo: 'deb     http://repositories.sensuapp.org/apt sensu main'
+      state: present
+      update_cache: true
+
+  - name: Ensure Sensu is installed
+    apt: name=sensu state={{ sensu_pkg_state }}

+ 22 - 0
tasks/Debian/rabbit.yml

@@ -0,0 +1,22 @@
+---
+# tasks/Debian/rabbit.yml: Deploy RabbitMQ
+# Specific to Debian
+
+  - include_vars: "{{ ansible_distribution }}.yml"
+
+  - name: Ensure the RabbitMQ APT repo GPG key is present
+    apt_key:
+      url: https://www.rabbitmq.com/rabbitmq-signing-key-public.asc
+      state: present
+
+  - name: Ensure the RabbitMQ APT repo is present
+    apt_repository:
+      repo: 'deb http://www.rabbitmq.com/debian/ testing main'
+      state: present
+      update_cache: true
+
+  - name: Ensure RabbitMQ is installed
+    apt:
+      name: rabbitmq-server
+      state: "{{ rabbitmq_pkg_state }}"
+      update_cache: true

+ 20 - 0
tasks/Debian/redis.yml

@@ -0,0 +1,20 @@
+---
+# tasks/Debian/redis.yml: Deploy Redis
+# Specific to Debian
+
+  - include_vars: "{{ ansible_distribution }}.yml"
+
+  - name: Ensure Redis is installed
+    apt:
+      name: "{{ redis_pkg_name }}"
+      state: "{{ redis_pkg_state }}"
+      update_cache: true
+
+  - name: Ensure Redis binds to accessible IP
+    lineinfile:
+      dest: /etc/redis/redis.conf
+      regexp: '^bind'
+      line: 'bind 0.0.0.0'
+    notify: restart redis service
+
+  - meta: flush_handlers

+ 1 - 1
tasks/Ubuntu/redis.yml

@@ -18,5 +18,5 @@
 
   - name: Deploy Redis systemd service manifest
     copy:
-      src: ubuntu_redis_systemd.service
+      src: redis_systemd.service
       dest: /etc/systemd/system/redis.service

+ 5 - 5
tasks/main.yml

@@ -6,6 +6,11 @@
   - include: "{{ ansible_distribution }}/main.yml"
     tags: setup
       
+  - include: redis.yml
+    tags: redis
+    when: redis_server
+          and sensu_deploy_redis
+
   - include: ssl.yml
     tags: ssl
 
@@ -14,11 +19,6 @@
     when: rabbitmq_server
           and sensu_deploy_rabbitmq
 
-  - include: redis.yml
-    tags: redis
-    when: redis_server
-          and sensu_deploy_redis
-
   - include: server.yml
     tags: server
     when: sensu_master

+ 1 - 1
tasks/redis.yml

@@ -4,4 +4,4 @@
   - include: "{{ ansible_distribution }}/redis.yml"
 
   - name: Ensure Redis is running
-    service: name=redis state=started enabled=true
+    service: name={{ redis_service_name }} state=started enabled=true

+ 1 - 1
tests/Vagrantfile

@@ -1,4 +1,4 @@
-vagrantfiles = %w[vms/Vagrantfile.centos7 vms/Vagrantfile.ubuntu15]
+vagrantfiles = %w[vms/Vagrantfile.centos7 vms/Vagrantfile.debian8 vms/Vagrantfile.ubuntu15]
 vagrantfiles.each do |vagrantfile|
   load File.expand_path(vagrantfile) if File.exists?(vagrantfile)
 end

+ 8 - 0
tests/provision.yml

@@ -1,5 +1,13 @@
 ---
 - hosts: all
 
+  vars:
+    sensu_ssl_client_cert: "data/dynamic/{{ ansible_hostname }}/etc/sensu/ssl_generation/sensu_ssl_tool/client/cert.pem"
+    sensu_ssl_client_key: "data/dynamic/{{ ansible_hostname }}/etc/sensu/ssl_generation/sensu_ssl_tool/client/key.pem"
+    sensu_ssl_server_cacert: "data/dynamic/{{ ansible_hostname }}/etc/sensu/ssl_generation/sensu_ssl_tool/sensu_ca/cacert.pem"
+    sensu_ssl_server_cert: "data/dynamic/{{ ansible_hostname }}/etc/sensu/ssl_generation/sensu_ssl_tool/server/cert.pem"
+    sensu_ssl_server_key: "data/dynamic/{{ ansible_hostname }}/etc/sensu/ssl_generation/sensu_ssl_tool/server/key.pem"
+
+
   roles:
     - ../../cmacrae.sensu

+ 4 - 4
tests/vms/Vagrantfile.centos7

@@ -11,7 +11,7 @@ Vagrant.configure(2) do | config |
    config.vm.define "centos7" do |centos7|
     centos7.vm.hostname = "centos7.dev"
     centos7.vm.box = "geerlingguy/centos7"
-    centos7.vm.network :private_network, ip: "192.168.40.3"
+    centos7.vm.network :private_network, ip: "192.168.40.4"
     centos7.vm.network "forwarded_port", guest: 3000, host: 3001
   end
 
@@ -25,11 +25,11 @@ Vagrant.configure(2) do | config |
 
     ansible.extra_vars = {
       dynamic_data_store: "data/dynamic",
-      rabbitmq_host: "192.168.40.3",
+      rabbitmq_host: "192.168.40.4",
       rabbitmq_server: true,
-      redis_host: "192.168.40.3",
+      redis_host: "192.168.40.4",
       redis_server: true,
-      sensu_api_host: "192.168.40.3",
+      sensu_api_host: "192.168.40.4",
       sensu_api_user_name: "admin",
       sensu_api_password: "admin",
       sensu_include_plugins: false,

+ 46 - 0
tests/vms/Vagrantfile.debian8

@@ -0,0 +1,46 @@
+############
+# Debian 8 #
+############
+Vagrant.configure(2) do | config |
+  config.ssh.insert_key = false
+  config.ssh.username = 'vagrant'
+  config.vm.provider :virtualbox do |vb|
+    vb.customize ["modifyvm", :id, "--memory", "2048"]
+  end
+
+   config.vm.define "debian8" do |debian8|
+    debian8.vm.hostname = "debian8.dev"
+    debian8.vm.box = "debian/jessie64"
+    debian8.vm.network :private_network, ip: "192.168.40.5"
+    debian8.vm.network "forwarded_port", guest: 3000, host: 3002
+  end
+
+  # Ansible
+  config.vm.provision "ansible" do |ansible|
+    ansible.groups = {
+      "sensu_masters" => ["debian8"],
+      "rabbitmq_servers" => ["debian8"],
+      "redis_servers" => ["debian8"],
+    }
+
+    ansible.extra_vars = {
+      dynamic_data_store: "data/dynamic",
+      rabbitmq_host: "192.168.40.5",
+      rabbitmq_server: true,
+      redis_host: "192.168.40.5",
+      redis_server: true,
+      sensu_api_host: "192.168.40.5",
+      sensu_api_user_name: "admin",
+      sensu_api_password: "admin",
+      sensu_include_plugins: false,
+      sensu_include_dashboard: true,
+      sensu_master: true,
+      uchiwa_dc_name: "vagrant",
+      uchiwa_user_name: "admin",
+      uchiwa_password: "admin",
+    }
+
+    ansible.sudo = true
+    ansible.playbook = "provision.yml"
+  end
+end

+ 5 - 5
tests/vms/Vagrantfile.ubuntu15

@@ -11,8 +11,8 @@ Vagrant.configure(2) do | config |
    config.vm.define "ubuntu15" do |ubuntu15|
     ubuntu15.vm.hostname = "ubuntu15.dev"
     ubuntu15.vm.box = "ubuntu/vivid64"
-    ubuntu15.vm.network :private_network, ip: "192.168.40.2"
-    ubuntu15.vm.network "forwarded_port", guest: 3000, host: 3000
+    ubuntu15.vm.network :private_network, ip: "192.168.40.6"
+    ubuntu15.vm.network "forwarded_port", guest: 3000, host: 3003
   end
 
   # Ansible
@@ -25,11 +25,11 @@ Vagrant.configure(2) do | config |
 
     ansible.extra_vars = {
       dynamic_data_store: "data/dynamic",
-      rabbitmq_host: "192.168.40.2",
+      rabbitmq_host: "192.168.40.6",
       rabbitmq_server: true,
-      redis_host: "192.168.40.2",
+      redis_host: "192.168.40.6",
       redis_server: true,
-      sensu_api_host: "192.168.40.2",
+      sensu_api_host: "192.168.40.6",
       sensu_api_user_name: "admin",
       sensu_api_password: "admin",
       sensu_include_plugins: false,

+ 15 - 0
vars/Debian.yml

@@ -0,0 +1,15 @@
+---
+# vars/Debian.yml: Variables for Debian
+# Defaults are defined in vars/default.yml
+
+# Redis server properties
+redis_pkg_name: redis-server
+redis_service_name: redis-server
+
+# Sensu/Uchiwa user/group/service properties
+sensu_user_name: root
+sensu_group_name: root
+uchiwa_pkg_download_sha256sum: 04d830e84159cc82b297ec9eb4333b8038b58ab77b12464163d7c5291bdda21d
+uchiwa_pkg_download_path: /root/uchiwa_latest.deb
+uchiwa_pkg_version: 0.14.2-1
+uchiwa_pkg_download_url: http://dl.bintray.com/palourde/uchiwa/uchiwa_{{ uchiwa_pkg_version }}_amd64.deb