ansible-doc -l |grep nginx
ansible-doc mysql_db
[root@rocky8 ~]# ansible-console 交互命令
-b 通过sudo执行
普通用户提权
被控制端创建luo用户设置密码,并提权
vi /etc/sudors
luo ALL=(ALL) NOPASSWD: ALL
控端生成密钥拷贝到被监控端
[luo@rocky8 ~]$ ssh-keygen -f ~/.ssh/id_rsa -P ''
[luo@rocky8 ~]$ ssh-copy-id luo@192.168.1.50
[luo@rocky8 ~]$ ssh-copy-id luo@192.168.1.51
bash
使用普通用户通过-b选项连接实现sudo提权后连接成功
[luo@rocky8 ~]$ ansible 192.168.1.51 -m shell -a 'ls /root' -b --become-user root
192.168.1.51 | CHANGED | rc=0 >>
1.sh
anaconda-ks.cfg
b.txt
cri-dockerd
cri-dockerd-0.3.1-3.el7.x86_64.rpm
go
go1.16.10.linux-amd64.tar.gz
mha4mysql-manager-0.58-0.el7.centos.noarch.rpm