ansible 学习笔记01

安装ansible

安装epel源、更改阿里源、安装ansible:

#yum -y install epel-release
#mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup
#mv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.backup
#wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
#yum -y install ansible

查看ansible 版本

[root@localhost ~]# ansible --version
ansible 2.9.9
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Oct 30 2018, 23:45:53) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]

体验单ansible命令

[root@localhost ~]#vim  /etc/ansible/hosts 
192.168.201.232 ansible_port=22 ansible_user=root ansible_ssh_pass=123456
[root@localhost ~]# ansible 192.168.201.232 -m ping
192.168.201.232 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": false, 
    "ping": "pong"
}
[root@localhost ~]# ansible 192.168.201.232 -m shell -a "hostname "
192.168.201.232 | CHANGED | rc=0 >>
ftp-server
posted @ 2020-06-18 16:17  Ant·Hanks  阅读(119)  评论(0)    收藏  举报