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

欢迎来撩 : 汇总all

白眉大叔

关于白眉大叔linux云计算: 白眉大叔

热门文章