📅  最后修改于: 2020-12-26 12:25:15             🧑  作者: Mango
以下是Ansible中使用的一些命令,例如:
[root@ansible-server ~]# sudo yum install epel-release
[root@ansible-server ~]# sudo yum install -y ansible
$ sudo apt update
$ sudo apt install software-properties-common
$ sudo apt-add-repository ppa:ansible/ansible
$ sudo apt update
$ sudo apt install ansible
[root@ansible-server test_ansible]# ansible -i hosts all -m ping
[root@ansible-server test_ansible]# ansible -i hosts all -m ping --limit host2
[root@ansible-server test_ansible]# ansible -i hosts all -m copy -a "src=/root/test_ansible/testfile dest=/tmp/testfile"
[root@ansible-server test_ansible]# ansible -i hosts all -m yum -a 'name=ncdu state=present'
[root@ansible-server test_ansible]# ansible -i hosts all -m yum -a 'name=ncdu state=absent'
[root@ansible-server test2]# ansible-galaxy init role1
[root@ansible-server test_ansible]# ansible-playbook -i hosts p4.yml --check
[root@ansible-server test_ansible]# ansible-playbook -i hosts p4.yml -k