Bläddra i källkod

CentOS 7 now supported!

cmacrae 9 år sedan
förälder
incheckning
fc325dd216

+ 11 - 1
README.md

@@ -18,12 +18,12 @@ This role deploys a full [Sensu](https://sensuapp.org) stack, a modern, open sou
 ### 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)
 
 ### Future Releases
 - OpenBSD
 - FreeBSD
 - NetBSD
-- EL (RHEL/CentOS)
 - Debian
 
 ## Role Variables
@@ -59,6 +59,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_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 |
 
@@ -124,6 +125,15 @@ 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 |
 
+## CentOS
+### [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_version` | _See `vars/CnetOS.yml`_ | The version of the Uchiwa package to fetch (specific to Linux systems) |
+| `uchiwa_pkg_download_url`  | _See `vars/CentOS.yml`_ | The URL of the Uchiwa package to fetch |
+
 ## SmartOS
 ### [RabbitMQ Server Properties](https://sensuapp.org/docs/0.21/rabbitmq)
 | Name               | Default Value | Description                  |

+ 1 - 0
defaults/main.yml

@@ -19,6 +19,7 @@ rabbitmq_sensu_vhost: /sensu
 redis_host: "{{ groups['redis_servers'][0] }}"
 redis_server: false
 redis_pkg_repo: ~
+redis_pkg_name: redis
 redis_pkg_state: present
 redis_port: 6379
 

+ 0 - 1
docs/afewwords.md

@@ -18,7 +18,6 @@ Coming in the near future:
 - OpenBSD
 - FreeBSD
 - NetBSD
-- EL
 - Debian
 
 I'd be happy to add any others to the list if high demand shows.

+ 1 - 1
docs/index.md

@@ -14,12 +14,12 @@ 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)
 
 ### Future Releases
 - OpenBSD
 - FreeBSD
 - NetBSD
-- EL (RHEL/CentOS)
 - Debian
 
 ## Role Variables

+ 11 - 0
docs/role_variables.md

@@ -28,6 +28,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_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 |
 
@@ -81,6 +82,7 @@ sensu_ssl_server_key: "{{ dynamic_data_store }}/{{ groups['sensu_masters'][0] }}
 | Name               | Default Value | Description                  |
 |--------------------|---------------|------------------------------|
 | `redis_pkg_repo`   | `'ppa:rwky/redis'` | The PPA to use for installing Redis from |
+| `redis_pkg_name` | redis-server |  The name of the Redis package to install |
 
 
 ### [Sensu Properties](https://sensuapp.org/docs/0.21/install-sensu)
@@ -93,6 +95,15 @@ 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 |
 
+## CentOS
+### [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_version` | _See `vars/CnetOS.yml`_ | The version of the Uchiwa package to fetch (specific to Linux systems) |
+| `uchiwa_pkg_download_url`  | _See `vars/CentOS.yml`_ | The URL of the Uchiwa package to fetch |
+
 ## SmartOS
 ### [RabbitMQ Server Properties](https://sensuapp.org/docs/0.21/rabbitmq)
 | Name               | Default Value | Description                  |

+ 9 - 2
docs/testing.md

@@ -2,9 +2,10 @@
 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`, after which you can visit the following URLs in your browser for the associated deployments:  
-- Ubuntu 15.04: `http://localhost:3000`
+- Ubuntu 15.04: `http://localhost:3000`  
+- CentOS 7: `http://localhost:3001`  
 
-_Note: Right now, there is only an Ubuntu 15.04 system available in the testing framework. To test SmartOS, please simply roll out a base64 zone_  
+_Note: To test SmartOS, please simply roll out a base64 zone_  
 
 To log in, use `admin` as both the username & password.  
 
@@ -12,9 +13,15 @@ To log in, use `admin` as both the username & password.
 As support for other operating systems/distributions is written, they will be added as options for testing.
 
 ## Caveats
+### Failing handlers
 It is expected that the following two handlers, triggered at the end of the test run will fail:  
 - `restart sensu-server service`  
 - `restart sensu-api service`  
 
 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`

+ 3 - 3
meta/main.yml

@@ -4,12 +4,12 @@ galaxy_info:
   license: MIT
   min_ansible_version: 2.0
   platforms:
-  #- name: EL
-  #  versions:
+  - name: EL
+    versions:
   #  - all
   #  - 5
   #  - 6
-  #  - 7
+    - 7
   #- name: GenericUNIX
   #  versions:
   #  - all

+ 16 - 0
tasks/CentOS/dashboard.yml

@@ -0,0 +1,16 @@
+---
+# tasks/CentOS/dashboard.yml: Deployment of the Uchiwa dashboard
+# Specific to CentOS
+
+  - include_vars: "{{ ansible_distribution }}.yml"
+
+  - name: Ensure Uchiwa is installed
+    yum:
+      name: "{{ uchiwa_pkg_download_url }}"
+      state: present
+
+  - name: Deploy Uchiwa config
+    template:
+      src: uchiwa_config.json.j2
+      dest: "{{ sensu_config_path }}/uchiwa.json"
+    notify: restart uchiwa service

+ 21 - 0
tasks/CentOS/main.yml

@@ -0,0 +1,21 @@
+---
+# tasks/CentOS/main.yml: CentOS specific set-up
+# This takes care of base prerequisites for CentOS
+
+  - include_vars: "{{ ansible_distribution }}.yml"
+
+  - name: Ensure the Sensu Core Yum repo is present
+    copy:
+      dest: /etc/yum.repos.d/sensu.repo
+      content: |
+        [sensu]
+        name=sensu
+        baseurl=http://repositories.sensuapp.org/yum/$basearch/
+        gpgcheck=0
+        enabled=1
+      owner: root
+      group: root
+      mode: 0644
+
+  - name: Ensure Sensu is installed
+    yum: name=sensu state={{ sensu_pkg_state }}

+ 13 - 0
tasks/CentOS/rabbit.yml

@@ -0,0 +1,13 @@
+---
+# tasks/CentOS/rabbit.yml: Deploy RabbitMQ
+# Specific to CentOS
+
+  - include_vars: "{{ ansible_distribution }}.yml"
+
+  - name: Ensure Erlang & RabbitMQ are installed
+    yum:
+      name:
+        - erlang
+        - rabbitmq-server
+      state: present
+      enablerepo: epel

+ 17 - 0
tasks/CentOS/redis.yml

@@ -0,0 +1,17 @@
+---
+# tasks/CentOS/redis.yml: Deploy Redis
+# Specific to CentOS
+
+  - include_vars: "{{ ansible_distribution }}.yml"
+
+  - name: Ensure Redis is installed
+    yum:
+      name: "{{ redis_pkg_name }}"
+      state: "{{ redis_pkg_state }}"
+      enablerepo: epel
+
+  - name: Ensure Redis binds to accessible IP
+    lineinfile:
+      dest: /etc/redis.conf
+      regexp: '^bind'
+      line: 'bind 0.0.0.0'

+ 1 - 1
tasks/Ubuntu/redis.yml

@@ -12,7 +12,7 @@
 
   - name: Ensure Redis is installed
     apt:
-      name: redis-server
+      name: "{{ redis_pkg_name }}"
       state: "{{ redis_pkg_state }}"
       update_cache: true
 

+ 1 - 1
tests/Vagrantfile

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

+ 46 - 0
tests/vms/Vagrantfile.centos7

@@ -0,0 +1,46 @@
+############
+# CentOS 7 #
+############
+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 "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 "forwarded_port", guest: 3000, host: 3001
+  end
+
+  # Ansible
+  config.vm.provision "ansible" do |ansible|
+    ansible.groups = {
+      "sensu_masters" => ["centos7"],
+      "rabbitmq_servers" => ["centos7"],
+      "redis_servers" => ["centos7"],
+    }
+
+    ansible.extra_vars = {
+      dynamic_data_store: "data/dynamic",
+      rabbitmq_host: "192.168.40.3",
+      rabbitmq_server: true,
+      redis_host: "192.168.40.3",
+      redis_server: true,
+      sensu_api_host: "192.168.40.3",
+      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

+ 9 - 0
vars/CentOS.yml

@@ -0,0 +1,9 @@
+---
+# vars/CentOS.yml: Variables for CentOS
+# Defaults are defined in vars/default.yml
+
+# Sensu/Uchiwa user/group/service properties
+sensu_user_name: root
+sensu_group_name: root
+uchiwa_pkg_version: 0.14.2-1
+uchiwa_pkg_download_url: http://dl.bintray.com/palourde/uchiwa/uchiwa-{{ uchiwa_pkg_version }}.x86_64.rpm

+ 1 - 0
vars/Ubuntu.yml

@@ -4,6 +4,7 @@
 
 # Redis server properties
 redis_pkg_repo: 'ppa:rwky/redis'
+redis_pkg_name: redis-server
 
 # Sensu/Uchiwa user/group/service properties
 sensu_user_name: root