运行Ansible剧本时出现以下错误:
[node1]
rabbit-node1 ansible_ssh_host=x.x.x.x ansible_ssh_user=ubuntu
[node2]
rabbit-node2 ansible_ssh_host=x.x.x.x ansible_ssh_user=ubuntu
[node3]
rabbit-node3 ansible_ssh_host=x.x.x.x ansible_ssh_user=ubuntu
[workers]
rabbit-node2
rabbit-node3
[all_group]
rabbit-node1
rabbit-node2
rabbit-node3
[all:vars]
ansible_python_interpreter=/usr/bin/python3
ansible_ssh_user=ubuntu
ansible_private_key_file=private key path
ansible_ssh_extra_args='-o StrictHostKeyChecking=no'
fatal: [rabbit-node1]: FAILED! => {"changed": false, "failed": true, "invocation": {"module_name": "setup"}, "module_stderr": "OpenSSH_7.2p2 Ubuntu-4ubuntu2.1, OpenSSL 1.0.2g 1 Mar 2016\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for x.x.x.x\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 25400\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\nShared connection to x.x.x.x closed.\r\n", "module_stdout": " File \"/home/ubuntu/.ansible/tmp/ansible-tmp-1584361123.7-96709661573808/setup\", line 3160\r\n except OSError, e:\r\n ^\r\nSyntaxError: invalid syntax\r\n", "msg": "MODULE FAILURE", "parsed": false}
3 playbook.yml
用于设置主机名的脚本文件,用于安装rabbitmq并创建具有3个节点的rabitmq集群。
- name: deploy RabbitMQ and setup the environment
hosts:
- all_group
#gather_facts: False
user: ubuntu
sudo: yes
roles:
- set_hostname
- install_rabbitmq
- name: Configure RabbitMQ Cluster
hosts:
- workers
user: ubuntu
sudo: yes
roles:
- cluster_setup