ansible的簡單應用


ansible的基本命令行應用mysql


ansible all -m command -a "/bin/echo hello" --ask-pass
ansible all -m ping --ask-pass -u root
ansible all -m script -a "/root/hequan/shell/t.sh" -k
ansible all -m copy -a "src=/root/hequan/shell/t.sh dest=/tmp/ mode=755 owner=root group=root" -k -u root
ansible all -m file -a "dest=/tmp/t.sh mode=755 owner=root group=root" -k -u root
ansible all -i /etc/ansible/serverlist -m shell -a "/tmp/t.sh" -k -u root
      
ansible all -m user -a "name=foo password=<crypted password here>"
ansible all -m user -a "name=foo state=absent"

ansible的playbook
sql

- hosts: mydb
  connection: local
  user: root
  gather_facts: false
  vars_files:
     - myvars.yml
- name: import database
  mysql_db: login_host=` DB_ADDRESS ` login_user=` DB_MASTER_USERNAME ` login_password=` DB_MASTER_PASSWORD ` name=mydb state=import target=roles/dbserver/templates/mydb.sql.j2
"""
相關文章
相關標籤/搜索