[icinga-checkins] icinga.org: icinga2-ansible/master: Create Web and IDO database seperately in web2

git at icinga.org git at icinga.org
Mon Jul 4 10:26:37 CEST 2016


Module: icinga2-ansible
Branch: master
Commit: 9c50df9ff15038ba281f2ff318d4c494f49e7d8e
URL:    https://git.icinga.org/?p=icinga2-ansible.git;a=commit;h=9c50df9ff15038ba281f2ff318d4c494f49e7d8e

Author: Robert Buchholz <rbu at goodpoint.de>
Date:   Thu Apr 21 19:14:46 2016 +0200

Create Web and IDO database seperately in web2

This cleans up the mix between IDO and icingaweb users and database,
where previously it would create an IDO database and import the web2
schema.
Also, privileges were incorrectly set on the username instead of the
db name (which just happened to be the same by default).

---

 doc/getting-started.md                             |    7 ++--
 icinga2-ansible-web2-ui/README.md                  |    2 +-
 icinga2-ansible-web2-ui/defaults/main.yml          |    7 ++++
 .../tasks/icinga2_web2_ui_RedHat_install.yml       |   40 ++++++++++++++++----
 4 files changed, 45 insertions(+), 11 deletions(-)

diff --git a/doc/getting-started.md b/doc/getting-started.md
index acdb5df..fe55503 100644
--- a/doc/getting-started.md
+++ b/doc/getting-started.md
@@ -85,15 +85,16 @@ After Icinga2 is up and running you can move forward to add IcingaWeb2 UI. Pleas
      tags: icinga2-no-ui
 
    - role: icinga2-ansible-web2-ui
+     icinga2_db_pass: "CHANGEME"
      icinga2_web2_db_pass: "CHANGEME"
      icinga2_ido_mysql_configuration: |
        library "db_ido_mysql"
 
        object IdoMysqlConnection "ido-mysql" {
-         user = "{{ icinga2_web2_db_user }}"
-         password = "{{ icinga2_web2_db_pass }}"
+         user = "{{ icinga2_db_user }}"
+         password = "{{ icinga2_db_pass }}"
          host = "localhost"
-         database = "{{ icinga2_web2_db }}"
+         database = "{{ icinga2_db }}"
        }
      tags: icinga2-ansible-web2-ui
 
diff --git a/icinga2-ansible-web2-ui/README.md b/icinga2-ansible-web2-ui/README.md
index d73c544..6a97454 100644
--- a/icinga2-ansible-web2-ui/README.md
+++ b/icinga2-ansible-web2-ui/README.md
@@ -43,6 +43,7 @@ Example Playbook
 
    - role: icinga2-ansible-web2-ui
      icinga2_db_pass: "CHANGEME"
+     icinga2_web2_db_pass: "CHANGEME"
      icinga2_ido_mysql_configuration: |
        library "db_ido_mysql"
 
@@ -70,4 +71,3 @@ Author Information
 ------------------
 
 Valentino Gagliardi - Icinga Dev Team
-
diff --git a/icinga2-ansible-web2-ui/defaults/main.yml b/icinga2-ansible-web2-ui/defaults/main.yml
index cf3786c..12168de 100644
--- a/icinga2-ansible-web2-ui/defaults/main.yml
+++ b/icinga2-ansible-web2-ui/defaults/main.yml
@@ -8,6 +8,13 @@ icinga2_mysql_schema_rh: "/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"
+
+
 enablerepo: "base"
 
 icinga2_web2_ui_rpm:
diff --git a/icinga2-ansible-web2-ui/tasks/icinga2_web2_ui_RedHat_install.yml b/icinga2-ansible-web2-ui/tasks/icinga2_web2_ui_RedHat_install.yml
index 78ea7ff..9daf59b 100644
--- a/icinga2-ansible-web2-ui/tasks/icinga2_web2_ui_RedHat_install.yml
+++ b/icinga2-ansible-web2-ui/tasks/icinga2_web2_ui_RedHat_install.yml
@@ -9,22 +9,22 @@
        state=latest
   when: ansible_pkg_mgr == "dnf"
 
-- name: Create a Database for Icinga2
+- name: Create a IDO Database for Icinga2
   mysql_db: name={{ icinga2_db }}
             state=present
-  register: icinga_web2_db
+  register: icinga_ido_db
 
-- name: Create Icinga Database User and configure Grants
-  mysql_user: name={{ icinga2_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_user }}.*:GRANT,INSERT,SELECT,UPDATE,DELETE,DROP,CREATE VIEW,INDEX,EXECUTE"
+              priv="{{ icinga2_db }}.*:GRANT,INSERT,SELECT,UPDATE,DELETE,DROP,CREATE VIEW,INDEX,EXECUTE"
 
 - name: Import the IDO Schema on Icinga Web Database (only once)
   mysql_db: name={{ icinga2_db }}
             state=import
-            target={{ icinga2_web_mysql_schema_rh }}
-  when: icinga_web2_db.changed == true
+            target={{ icinga2_mysql_schema_rh }}
+  when: icinga_ido_db.changed == true
 
 - name: Configure Icinga2 Ido Mysql Feature
   template: src=ido-mysql.conf.j2
@@ -57,6 +57,32 @@
   tags: icinga2-ansible-web2-ui-install
   when: ansible_pkg_mgr == "dnf"
 
+
+- 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"
+
+- name: Import the Web Schema on Icinga Web Database (only once)
+  mysql_db: name={{ icinga2_web2_db }}
+            state=import
+            target={{ icinga2_web2_mysql_schema_rh }}
+  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=icinga
+            group=icinga
+            mode=0640
+
 - name: Restart HTTPD and Icinga2 to Apply the Configuration
   service: name={{ item }}
            state=restarted



More information about the icinga-checkins mailing list