From e101d2f42c2b6d67b57f87952e3a416e9cda232f Mon Sep 17 00:00:00 2001 From: A Holt Date: Sun, 28 Oct 2018 12:03:35 -0400 Subject: [PATCH] Update main.yml --- roles/mysql/tasks/main.yml | 254 ++++++++++++++++++------------------- 1 file changed, 126 insertions(+), 128 deletions(-) diff --git a/roles/mysql/tasks/main.yml b/roles/mysql/tasks/main.yml index 8fccfaf09..b8976373b 100644 --- a/roles/mysql/tasks/main.yml +++ b/roles/mysql/tasks/main.yml @@ -1,148 +1,146 @@ - - name: Install MySQL (debuntu) - package: - name: "{{ item }}" - state: present - with_items: - - mariadb-server - - mariadb-client - - python-mysqldb - - php{{ php_version }} - - php{{ php_version }}-mysql - - php-pear - - php{{ php_version }}-gd - - php{{ php_version }}-imap - - php{{ php_version }}-ldap - - php{{ php_version }}-odbc -# - php{{ php_version }}-xml - - php{{ php_version }}-xmlrpc - when: is_debuntu - tags: - - download +- name: Install MySQL (debuntu) + package: + name: + - mariadb-server + - mariadb-client + - python-mysqldb + - php{{ php_version }} + - php{{ php_version }}-mysql + - php-pear + - php{{ php_version }}-gd + - php{{ php_version }}-imap + - php{{ php_version }}-ldap + - php{{ php_version }}-odbc + #- php{{ php_version }}-xml + - php{{ php_version }}-xmlrpc + state: present + when: is_debuntu + tags: + - download - - name: php-xml (ubuntu or debian-9) - package: - name: "php{{ php_version }}-xml" - state: present - when: is_ubuntu or is_debian_9 +- name: php-xml (ubuntu or debian-9) + package: + name: "php{{ php_version }}-xml" + state: present + when: is_ubuntu or is_debian_9 - - name: php-xml (debian-8) - package: - name: "php-xml-parser" - state: present - when: is_debian_8 +- name: php-xml (debian-8) + package: + name: "php-xml-parser" + state: present + when: is_debian_8 - - name: Install MySQL (OS's other than debuntu) - package: - name: "{{ item }}" - state: present - with_items: - - MySQL-python - - mysql - - php - - php-mysql - - php-pear - - php-gd - - php-imap - - php-ldap - - php-odbc - - php-xml - - php-xmlrpc - when: not is_debuntu - tags: - - download +- name: Install MySQL (OS's other than debuntu) + package: + name: + - MySQL-python + - mysql + - php + - php-mysql + - php-pear + - php-gd + - php-imap + - php-ldap + - php-odbc + - php-xml + - php-xmlrpc + state: present + when: not is_debuntu + tags: + - download - - include_tasks: centos.yml - when: ansible_distribution == "CentOS" - tags: - - download +- include_tasks: centos.yml + when: ansible_distribution == "CentOS" + tags: + - download - - include_tasks: fedora.yml - when: ansible_distribution == "Fedora" - tags: - - download +- include_tasks: fedora.yml + when: ansible_distribution == "Fedora" + tags: + - download # Name of mysql service varies by OS so softcoded in 1-prep - - name: Start the MySQL service - service: - name: "{{ mysql_service }}" - state: started +- name: Start the MySQL service + service: + name: "{{ mysql_service }}" + state: started - - name: Enable the MySQL service - service: - name: "{{ mysql_service }}" - enabled: yes - when: mysql_enabled +- name: Enable the MySQL service + service: + name: "{{ mysql_service }}" + enabled: yes + when: mysql_enabled # 'localhost' needs to be the last item for idempotency, see # http://ansible.cc/docs/modules.html#mysql-user # unfortunately it still doesn't work - - name: Update MySQL root password for localhost root accounts - mysql_user: - name: root - host: "{{ item }}" - password: "{{ mysql_root_password }}" - priv: "*.*:ALL,GRANT" - with_items: - - localhost - when: mysql_enabled +- name: Update MySQL root password for localhost root accounts + mysql_user: + name: root + host: "{{ item }}" + password: "{{ mysql_root_password }}" + priv: "*.*:ALL,GRANT" + with_items: + - localhost + when: mysql_enabled - - name: Copy .my.cnf file with root password credentials - template: - src: my.cnf.j2 - dest: /root/.my.cnf - owner: root - mode: 0600 - when: mysql_enabled +- name: Install .my.cnf file from template, with root password credentials + template: + src: my.cnf.j2 + dest: /root/.my.cnf + owner: root + mode: 0600 + when: mysql_enabled - - name: Update MySQL root password for all remaining root accounts - mysql_user: - name: root - host: "{{ item }}" - password: "{{ mysql_root_password }}" - priv: "*.*:ALL,GRANT" - with_items: -# - "{{ iiab_hostname }}.{{ iiab_domain }}" - - 127.0.0.1 - - ::1 - when: mysql_enabled +- name: Update MySQL root password for all remaining root accounts + mysql_user: + name: root + host: "{{ item }}" + password: "{{ mysql_root_password }}" + priv: "*.*:ALL,GRANT" + with_items: + #- "{{ iiab_hostname }}.{{ iiab_domain }}" + - 127.0.0.1 + - ::1 + when: mysql_enabled - - name: Delete anonymous MySQL server user for {{ ansible_hostname }} - mysql_user: - user: "" - host: "{{ ansible_hostname }}" - state: absent - when: mysql_enabled +- name: Delete anonymous MySQL server user for {{ ansible_hostname }} + mysql_user: + user: "" + host: "{{ ansible_hostname }}" + state: absent + when: mysql_enabled - - name: Delete anonymous MySQL server user for localhost - mysql_user: - user: "" - state: absent - when: mysql_enabled +- name: Delete anonymous MySQL server user for localhost + mysql_user: + user: "" + state: absent + when: mysql_enabled - - name: Remove the MySQL test database - mysql_db: - db: test - state: absent - when: mysql_enabled +- name: Remove the MySQL test database + mysql_db: + db: test + state: absent + when: mysql_enabled # we had to start mysql in order to configure it, now turn if off if not enabled - - name: Provisionally Disable the MySQL service - service: - name: "{{ mysql_service }}" - enabled: no - state: stopped - when: not mysql_enabled +- name: Provisionally Disable the MySQL service + service: + name: "{{ mysql_service }}" + enabled: no + state: stopped + when: not mysql_enabled - - name: Add 'mysql' to list of services at {{ iiab_ini_file }} - ini_file: - dest: "{{ iiab_ini_file }}" - section: mysql - option: "{{ item.option }}" - value: "{{ item.value }}" - with_items: - - option: name - value: MySQL - - option: description - value: '"MySQL is a widely used free and open source (GPLv2) database, offered by most web hosting services, on a diversity of platforms."' - - option: enabled - value: "{{ mysql_enabled }}" +- name: Add 'mysql' to list of services at {{ iiab_ini_file }} + ini_file: + dest: "{{ iiab_ini_file }}" + section: mysql + option: "{{ item.option }}" + value: "{{ item.value }}" + with_items: + - option: name + value: MySQL + - option: description + value: '"MySQL is a widely used free and open source (GPLv2) database, offered by most web hosting services, on a diversity of platforms."' + - option: enabled + value: "{{ mysql_enabled }}"