Centos8.1 配置ansible
  IOx06cE9KKpI 2023年11月02日 41 0


1、安装步骤
安装epel扩展源

dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y

dnf安装ansible

dnf --installroot=/apps/ansible --releasever=/ install ansible -y

2、验证
ansible --version

[root@centos8 ~]# ansible --version
ansible 2.9.18
config file = /etc/ansible/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.6/site-packages/ansible
executable location = /usr/bin/ansible
python version = 3.6.8 (default, Nov 21 2019, 19:31:34) [GCC 8.3.1 20190507 (Red Hat 8.3.1-4)]
[root@centos8 ~]#

3,编辑hosts文件
加入如下:

[csctbb]
192.168.43.151
#192.168.43.152
[csctbb:vars]
ansible_ssh_port=22
ansible_ssh_user=root
ansible_ssh_pass=root

测试查看远程服务器的运行时间

[root@centos8 ansible]# ansible csctbb -m command -a 'uptime'
192.168.43.151 | CHANGED | rc=0 >>
15:19:42 up 1 min, 2 users, load average: 1.12, 0.72, 0.28

用来测试远程主机的运行状态

[root@centos8 ansible]# ansible csctbb -m ping
192.168.43.151 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/libexec/platform-python"
},
"changed": false,
"ping": "pong"
}


【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

推荐阅读
  4koL3J55wyKx   2023年11月13日   36   0   0 icogitCentOS
  9E2BTpjt8nym   2023年12月06日   34   0   0 WindowsgitCentOS
IOx06cE9KKpI