51工具盒子

依楼听风雨
笑看云卷云舒,淡观潮起潮落

ansible roles mysql

[root@m01 /etc/ansible/roles/mysqlserver/tasks]#cat main.yml 
- name: Install MariaDb-Server
  yum:
    name: 
      - mariadb-server
      - MySQL-python
    state: present
- name: Start Mariadb Server
  systemd: 
    name: mariadb
    state: started
    enabled: yes
#- name: configure login passwd
#  shell:
#    cmd: mysqladmin password '123456' 

- name: copy all.sql to Db01
  copy: 
      src: all.sql
      dest: /root/all.sql
- name: Import all.sql to Myariadb
  mysql_db:
      login_host: 172.16.1.51
      login_port: 3306
      login_user: root
      name: all
      state: import
      target: /root/all.sql
- name: Restart Mariadb Server
  systemd:
      name: mariadb
      state: restarted

上边的思路有问题的,

我们知识提供部署,mysql 服务,

但是具体的业务导入,需要单独的拿出来放到 wordpress 业务中的。


mysql.yml 原始配置文件

|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [root@m01 ~/ansible]#cat mysql.yml - hosts: db01 tasks: - name: Install MariaDb-Server yum: name: - mariadb-server - MySQL-python state: present - name: Start Mariadb Server systemd: name: mariadb state: started enabled: yes - name: copy all.sql to Db01 copy: src: all.sql dest: /root/all.sql - name: Import all.sql to Myariadb mysql_db: login_host: localhost #做好改成 ip login_port: 3306 login_user: root name: all state: import target: /root/all.sql - name: Restart Mariadb Server systemd: name: mariadb state: restarted |

赞(7)
未经允许不得转载:工具盒子 » ansible roles mysql