From ea36d978982f6fe6304040940f930021b1a72af2 Mon Sep 17 00:00:00 2001 From: Thomas Duemesnil Date: Sun, 22 May 2016 17:42:05 +0200 Subject: [PATCH 1/4] Modified Variable notation to new Ansible standard --- icinga2-ansible-no-ui/tasks/icinga2_Debian_install.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/icinga2-ansible-no-ui/tasks/icinga2_Debian_install.yml b/icinga2-ansible-no-ui/tasks/icinga2_Debian_install.yml index f7760a79..60180eed 100644 --- a/icinga2-ansible-no-ui/tasks/icinga2_Debian_install.yml +++ b/icinga2-ansible-no-ui/tasks/icinga2_Debian_install.yml @@ -13,7 +13,7 @@ apt_repository: repo='{{ item.repo }}' update_cache=yes state=present - with_items: icinga2_deb_repos + with_items: '{{ icinga2_deb_repos }}' #Debian packages require additional packages which are provided by the Debian Monitoring Project repository - name: Get Debmon Apt Repo for Debian OS family (Debian) @@ -27,7 +27,7 @@ update_cache=yes state=latest install_recommends=no - with_items: icinga2_pkg + with_items: '{{ icinga2_pkg }}' - name: Start Icinga2 service: name=icinga2 From a0a2aca94afe2e5606f96b988c9523d6653ab753 Mon Sep 17 00:00:00 2001 From: Thomas Duemesnil Date: Sun, 22 May 2016 17:56:13 +0200 Subject: [PATCH 2/4] Added Debian Branch for Web2 ui script --- icinga2-ansible-web2-ui/defaults/main.yml | 11 ++ .../tasks/icinga2_web2_ui_Debian_install.yml | 104 ++++++++++++++++++ icinga2-ansible-web2-ui/tasks/main.yml | 3 + 3 files changed, 118 insertions(+) create mode 100644 icinga2-ansible-web2-ui/tasks/icinga2_web2_ui_Debian_install.yml diff --git a/icinga2-ansible-web2-ui/defaults/main.yml b/icinga2-ansible-web2-ui/defaults/main.yml index cf3786c4..6e0717ea 100644 --- a/icinga2-ansible-web2-ui/defaults/main.yml +++ b/icinga2-ansible-web2-ui/defaults/main.yml @@ -5,11 +5,22 @@ icinga2_db: "icinga" icinga2_db_pass: "icinga" icinga2_db_user: "icinga" icinga2_mysql_schema_rh: "/usr/share/icinga2-ido-mysql/schema/mysql.sql" +icinga2_mysql_schema_debian: "/usr/share/icinga2-ido-mysql/schema/mysql.sql" icinga2_ido_mysql_conf: "/etc/icinga2/features-available/ido-mysql.conf" icinga2_ido_mysql_configuration: "none" + +icinga2_web2_db: "icingaweb" +icinga2_web2_db_pass: "icingaweb" +icinga2_web2_db_user: "icingaweb" +icinga2_web2_mysql_schema_rh: "/usr/share/doc/icingaweb2/schema/mysql.schema.sql" +icinga2_web2_mysql_schema_debian: "/usr/share/icingaweb2/etc/schema/mysql.schema.sql" + enablerepo: "base" icinga2_web2_ui_rpm: - { package: "icingaweb2" } - { package: "icingacli" } + +icinga2_web2_ui_deb: + - { package: "icingaweb2" } diff --git a/icinga2-ansible-web2-ui/tasks/icinga2_web2_ui_Debian_install.yml b/icinga2-ansible-web2-ui/tasks/icinga2_web2_ui_Debian_install.yml new file mode 100644 index 00000000..e5575710 --- /dev/null +++ b/icinga2-ansible-web2-ui/tasks/icinga2_web2_ui_Debian_install.yml @@ -0,0 +1,104 @@ +--- +- name: Install Icinga2 IDO modules on Debian family + apt: name=icinga2-ido-mysql + state=latest + +- name: Create a IDO Database for Icinga2 + mysql_db: name={{ icinga2_db }} + state=present + login_user=root + login_password={{ mysql_root_db_pass }} + register: icinga_ido_db + +- name: Create Icinga2 IDO Database User and configure Grants + mysql_user: name={{ icinga2_db_user }} + password={{ icinga2_db_pass }} + state=present + priv="{{ icinga2_db }}.*:GRANT,INSERT,SELECT,UPDATE,DELETE,DROP,CREATE VIEW,INDEX,EXECUTE" + login_user=root + login_password={{ mysql_root_db_pass }} + +- name: Import the IDO Schema on Icinga Web Database (only once) + mysql_db: name={{ icinga2_db }} + state=import + target={{ icinga2_mysql_schema_debian }} + login_user=root + login_password={{ mysql_root_db_pass }} + when: icinga_ido_db.changed == true + +- name: Configure Icinga2 Ido Mysql Feature + template: src=ido-mysql.conf.j2 + dest={{ icinga2_ido_mysql_conf }} + backup=yes + owner=nagios + group=nagios + mode=0640 + +- name: Enable Icinga2 Ido Mysql Feature + command: "icinga2 feature enable ido-mysql" + register: features_result + changed_when: "'for these changes to take effect' in features_result.stdout" + notify: + - restart icinga2 + +- name: Install Icinga Web2 on Debian family + apt: name={{ item.package }} + state=latest + with_items: '{{ icinga2_web2_ui_deb }}' + tags: icinga2-ansible-web2-ui-install + +- name: Create a Web Database for Icinga2 + mysql_db: name={{ icinga2_web2_db }} + state=present + register: icinga_web_db + +- name: Create Icinga2 Web Database User and configure Grants + mysql_user: name={{ icinga2_web2_db_user }} + password={{ icinga2_web2_db_pass }} + state=present + priv="{{ icinga2_web2_db }}.*:GRANT,INSERT,SELECT,UPDATE,DELETE,DROP,CREATE VIEW,INDEX,EXECUTE" + login_user=root + login_password={{ mysql_root_db_pass }} + +- name: Import the Web Schema on Icinga Web Database (only once) + mysql_db: name={{ icinga2_web2_db }} + state=import + target={{ icinga2_web2_mysql_schema_debian }} + when: icinga_web_db.changed == true + +- name: Configure Icinga2 Ido Mysql Feature + template: src=ido-mysql.conf.j2 + dest={{ icinga2_ido_mysql_conf }} + backup=yes + owner=nagios + group=nagios + mode=0640 + +- name: Restart HTTPD and Icinga2 to Apply the Configuration + service: name={{ item }} + state=restarted + enabled=yes + with_items: + - apache2 + - icinga2 + +- name: Add user www-data to group icingaweb2 + user: name=www-data + groups=icingaweb2 + +- name: Adjust Directory Owener and Group + file: path=/etc/icingaweb2/modules owner=www-data group=icingaweb2 mode=0755 + state=directory + recurse=yes + +- name: Create Directory Owener and Group + file: path=/etc/icingaweb2/modules/{{ item }} owner=www-data group=icingaweb2 mode=0755 + state=directory + with_items: + - monitoring + - translation + +- name: Icinga Web2 Installation finished (Debian) + debug: msg="Now generate a token with 'icingacli setup token create' and go at http://IP//icingaweb2/setup to continue the installation" + tags: icinga2-ansible-web2-ui-install + diff --git a/icinga2-ansible-web2-ui/tasks/main.yml b/icinga2-ansible-web2-ui/tasks/main.yml index a52d597b..9fccfbb4 100644 --- a/icinga2-ansible-web2-ui/tasks/main.yml +++ b/icinga2-ansible-web2-ui/tasks/main.yml @@ -3,3 +3,6 @@ - include: icinga2_web2_ui_RedHat_install.yml when: ansible_os_family == 'RedHat' + +- include: icinga2_web2_ui_Debian_install.yml + when: ansible_os_family == 'Debian' From 3464f67761e2143d378ea0d9a088930617922f23 Mon Sep 17 00:00:00 2001 From: Thomas Duemesnil Date: Wed, 6 Jul 2016 17:38:13 +0200 Subject: [PATCH 3/4] Variable name changed --- .../tasks/icinga2_web2_ui_Debian_install.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/icinga2-ansible-web2-ui/tasks/icinga2_web2_ui_Debian_install.yml b/icinga2-ansible-web2-ui/tasks/icinga2_web2_ui_Debian_install.yml index e5575710..99a02ef9 100644 --- a/icinga2-ansible-web2-ui/tasks/icinga2_web2_ui_Debian_install.yml +++ b/icinga2-ansible-web2-ui/tasks/icinga2_web2_ui_Debian_install.yml @@ -6,7 +6,7 @@ - name: Create a IDO Database for Icinga2 mysql_db: name={{ icinga2_db }} state=present - login_user=root + login_user=root login_password={{ mysql_root_db_pass }} register: icinga_ido_db @@ -15,14 +15,14 @@ password={{ icinga2_db_pass }} state=present priv="{{ icinga2_db }}.*:GRANT,INSERT,SELECT,UPDATE,DELETE,DROP,CREATE VIEW,INDEX,EXECUTE" - login_user=root + login_user=root login_password={{ mysql_root_db_pass }} - name: Import the IDO Schema on Icinga Web Database (only once) mysql_db: name={{ icinga2_db }} state=import - target={{ icinga2_mysql_schema_debian }} - login_user=root + target={{ icinga2_web_mysql_schema_debian }} + login_user=root login_password={{ mysql_root_db_pass }} when: icinga_ido_db.changed == true @@ -44,7 +44,7 @@ - name: Install Icinga Web2 on Debian family apt: name={{ item.package }} state=latest - with_items: '{{ icinga2_web2_ui_deb }}' + with_items: '{{ icinga2_web2_ui_deb }}' tags: icinga2-ansible-web2-ui-install - name: Create a Web Database for Icinga2 @@ -52,7 +52,7 @@ state=present register: icinga_web_db -- name: Create Icinga2 Web Database User and configure Grants +- name: Create Icinga2 Web Database User and configure Grants mysql_user: name={{ icinga2_web2_db_user }} password={{ icinga2_web2_db_pass }} state=present @@ -83,7 +83,7 @@ - icinga2 - name: Add user www-data to group icingaweb2 - user: name=www-data + user: name=www-data groups=icingaweb2 - name: Adjust Directory Owener and Group @@ -94,7 +94,7 @@ - name: Create Directory Owener and Group file: path=/etc/icingaweb2/modules/{{ item }} owner=www-data group=icingaweb2 mode=0755 state=directory - with_items: + with_items: - monitoring - translation From 4b0948b85070f7a914561a25672e5a322bf4fda8 Mon Sep 17 00:00:00 2001 From: Thomas Duemesnil Date: Thu, 7 Jul 2016 09:33:17 +0200 Subject: [PATCH 4/4] Removed the User and password parameter from mysql task to stay compatible with the rh script. --- .../tasks/icinga2_web2_ui_Debian_install.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/icinga2-ansible-web2-ui/tasks/icinga2_web2_ui_Debian_install.yml b/icinga2-ansible-web2-ui/tasks/icinga2_web2_ui_Debian_install.yml index 99a02ef9..5f026087 100644 --- a/icinga2-ansible-web2-ui/tasks/icinga2_web2_ui_Debian_install.yml +++ b/icinga2-ansible-web2-ui/tasks/icinga2_web2_ui_Debian_install.yml @@ -6,8 +6,6 @@ - name: Create a IDO Database for Icinga2 mysql_db: name={{ icinga2_db }} state=present - login_user=root - login_password={{ mysql_root_db_pass }} register: icinga_ido_db - name: Create Icinga2 IDO Database User and configure Grants @@ -15,15 +13,11 @@ password={{ icinga2_db_pass }} state=present priv="{{ icinga2_db }}.*:GRANT,INSERT,SELECT,UPDATE,DELETE,DROP,CREATE VIEW,INDEX,EXECUTE" - login_user=root - login_password={{ mysql_root_db_pass }} - name: Import the IDO Schema on Icinga Web Database (only once) mysql_db: name={{ icinga2_db }} state=import target={{ icinga2_web_mysql_schema_debian }} - login_user=root - login_password={{ mysql_root_db_pass }} when: icinga_ido_db.changed == true - name: Configure Icinga2 Ido Mysql Feature @@ -57,8 +51,6 @@ password={{ icinga2_web2_db_pass }} state=present priv="{{ icinga2_web2_db }}.*:GRANT,INSERT,SELECT,UPDATE,DELETE,DROP,CREATE VIEW,INDEX,EXECUTE" - login_user=root - login_password={{ mysql_root_db_pass }} - name: Import the Web Schema on Icinga Web Database (only once) mysql_db: name={{ icinga2_web2_db }}