- name: "del mysql user" user: name: mysql state: absent remove: yes - name: "del mariadb|mysql" yum: name: mysql state: removed yum: name: mariadb state: removed - name: "copy mysql.zip" synchronize: src: "{{ role_path }}/files/" dest: "/tmp/" - name: "add mysql user" shell: useradd mysql -s /sbin/nologin -M - name: "mkdir /home/database/" file: path: /home/database state: directory - name: "mkdir /home/database/dbdata/" file: path: /home/database/dbdata state: directory owner: mysql group: mysql - name: "mkdir /var/lib/mysql/" file: path: /var/lib/mysql/ state: directory owner: mysql group: mysql mode: 1777 - name: "mkdir /etc/mysql/" file: path: /etc/mysql/ state: directory - name: "mkdir /var/log/mariadb/" file: path: /var/log/mariadb/ state: directory - name: "set /tmp permission 1777" shell: chmod 1777 /tmp - name: "unarchive mariadb" unarchive: src: "/tmp/mysql.zip" dest: "/home/database/" copy: no - name: "install libaio-devel" yum: name: - /tmp/libaio-devel-0.3.109-13.el7.x86_64.rpm state: present - name: "init mariadb" shell: cd /home/database/mysql/scripts;./mysql_install_db --basedir=/home/database/mysql --datadir=/home/database/dbdata --user=mysql - name: "set my.cnf" copy: src: "{{ role_path }}/files/my.cnf" dest: "/etc/mysql/my.cnf" - name: "copy mariadb" copy: src: "{{ role_path }}/files/mariadb" dest: "/etc/init.d/" mode: 0755 - name: "copy mariadb.service" copy: src: "{{ role_path }}/files/mariadb.service" dest: "/usr/lib/systemd/system/" mode: 0755 - name: "copy mysql" shell: cp -rf /home/database/mysql/bin/mysql /usr/local/bin - name: "copy mysqladmin" shell: cp -rf /home/database/mysql/bin/mysqladmin /usr/local/bin - name: "start and enable mariadb" systemd: name: mariadb state: started enabled: yes daemon_reload: yes - name: "set mariadb password" shell: mysqladmin password {{ mariadb.password }} - name: "set mariadb privileges" shell: mysql -uroot -p{{ mariadb.password }} -e "grant all privileges on *.* to root@'%' identified by 'tsg2019' with grant option;" shell: mysql -uroot -p{{ mariadb.password }} -e "flush privileges;" shell: mysql -uroot -p{{ mariadb.password }} -e "create database tsg_oam" - name: "get remote tsg sn" shell: cat /opt/tsg/etc/tsg_sn.json | grep sn | awk -F "\"" {'print $4'} register: adc_tsg_sn - name: "Templates tsg_threshold.sql" template: src: "{{role_path}}/templates/tsg_threshold.sql.j2" dest: /tmp/tsg-cli-deploy/tsg_threshold.sql tags: template - name: "debug show tsg_sn" debug: var=adc_tsg_sn.stdout - name: "import the sql after template" shell: mysql -s -h 127.0.0.1 -u {{ mariadb.username }} -p{{ mariadb.password }} < /tmp/tsg-cli-deploy/tsg_threshold.sql