ansible--我的几个报错

时间:2023-01-19 19:29:53

我的几个报错:

1.远程复制失败

[root@localhost ~ ]#scp -r .ssh 192.168.10.145:/root/

root@192.168.10.145's password:

bash: scp: command not found

lost connection

解决思路:发现没装openssh-clients客户端工具

[root@centos6 ~ ]#rpm -qa openssh*

openssh-5.3p1-122.el6.x86_64

openssh-server-5.3p1-122.el6.x86_64

[root@centos6 ~ ]#yum install openssh-clients

3.
[root@ansible /etc/ansible ]#ansible-playbook -C nginx.yml
[WARNING]: While constructing a mapping from /etc/ansible/roles/nginx/tasks/main.yml, line 6, column 3, found a duplicate dict key (template). Using
last defined value only.

[WARNING]: Ignoring invalid attribute: with_item

4.
fatal: [192.168.10.145]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'item' is undefined\n\nThe error appears to have been in '/etc/ansible/roles/nginx/handlers/main.yml': line 1, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: reload the service\n ^ here\n"}
fatal: [192.168.10.144]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'item' is undefined\n\nThe error appears to have been in '/etc/ansible/roles/nginx/handlers/main.yml': line 1, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: reload the service\n ^ here\n"}

装这几个工具是方便-键操作

yum install ntpdate -y

ansible all -a 'yum install ntpdate -y'

ansible all -a '/usr/sbin/ntpdate stdtime.gov.hk'

ansible all -a 'yum install tree -y'

ansible all -a 'yum install openssh-clients -y'

2.同步失败

[root@centos7 ~ ]#ansible all -a 'ntpdate time.nist.gov'

192.168.10.144 | FAILED | rc=1 >>

5 May 19:00:00 ntpdate[37327]: no server suitable for synchronization foundnon-zero return code

解决方法:

第1:先要确定,系统确实可以上网,ping baidu.com 能通就行

第2:/usr/sbin/ntpdate stdtime.gov.hk 就行了