0

我正在关注此博客以使用 ansible 在 OpenStack 上安装 OpenShift Origin V3。但我收到错误

“无法创建事实文件:%s,错误:%s”%(文件名,ex) main .OpenShiftFactsFileWriteError:无法创建事实文件:/etc/ansible/facts.d/openshift.fact,错误:[Errno 13]权限被拒绝:'/etc/ansible/facts.d'

目标系统是 CentOS,我可以在目标系统上执行无密码 sudo。我什至添加了/etc/sudoers

centos 全部=(ALL) NOPASSWD:ALL

到所有节点以及我运行ansible的系统上。

在我运行 ansible 的系统中,我尝试以 sudo 和 root 身份执行,但结果相同。

我不确定它在哪里面临权限被拒绝,我的意思是在主机或目标系统上。

Ansible 主机:

[OSEv3:children"]
masters
nodes

[OSEv3:vars]
ansible_ssh_user=centos
ansible_sudo=true
#ansible_ssh_user=root

product_type=openshift
deployment_type=origin

[masters]
192.168.144.132 openshift_public_hostname=master.novalocal openshift_ip=10.0.1.163 openshift_public_ip=192.168.144.132

[nodes]
192.168.144.128 openshift_public_hostname=node1.novalocal openshift_ip=10.0.1.164 openshift_public_ip=192.168.144.128 openshift_node_labels="{'region': 'primary', 'zone': 'east'}" 
192.168.144.129 openshift_public_hostname=node2.novalocal openshift_ip=10.0.1.165 openshift_public_ip=192.168.144.129 openshift_node_labels="{'region': 'primary', 'zone': 'west'}"

Ansible.cfg

[defaults]
hostfile = ansible_hosts
remote_user = centos
host_key_checking = False

以下是日志:

TASK: [openshift_facts | Ensure PyYaml is installed] ************************** 
ok: [192.168.144.132] => (item=PyYAML)

TASK: [openshift_facts | Gather Cluster facts] ******************************** 
failed: [192.168.144.132] => {"failed": true, "parsed": false}
Traceback (most recent call last):
  File "/home/centos/.ansible/tmp/ansible-tmp-1449035570.03-273189812167365/openshift_facts", line 6355, in <module>
    main()
  File "/home/centos/.ansible/tmp/ansible-tmp-1449035570.03-273189812167365/openshift_facts", line 1222, in main
    openshift_facts = OpenShiftFacts(role, fact_file, local_facts, additive_facts_to_overwrite)
  File "/home/centos/.ansible/tmp/ansible-tmp-1449035570.03-273189812167365/openshift_facts", line 999, in __init__
    self.facts = self.generate_facts(local_facts, additive_facts_to_overwrite)
  File "/home/centos/.ansible/tmp/ansible-tmp-1449035570.03-273189812167365/openshift_facts", line 1013, in generate_facts
    local_facts = self.init_local_facts(local_facts, additive_facts_to_overwrite)
  File "/home/centos/.ansible/tmp/ansible-tmp-1449035570.03-273189812167365/openshift_facts", line 1194, in init_local_facts
    save_local_facts(self.filename, new_local_facts)
  File "/home/centos/.ansible/tmp/ansible-tmp-1449035570.03-273189812167365/openshift_facts", line 924, in save_local_facts
    "Could not create fact file: %s, error: %s" % (filename, ex)
__main__.OpenShiftFactsFileWriteError: Could not create fact file: /etc/ansible/facts.d/openshift.fact, error: [Errno 13] Permission denied: '/etc/ansible'
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: auto-mux: Trying existing master
debug1: mux_client_request_session: master session id: 2
Shared connection to 192.168.144.132 closed.


FATAL: all hosts have already failed -- aborting

PLAY RECAP ******************************************************************** 
           to retry, use: --limit @/root/config.retry

192.168.144.132            : ok=6    changed=0    unreachable=0    failed=1   
localhost                  : ok=7    changed=0    unreachable=0    failed=0   

我以前没有使用 ansible 的经验,因此我无法进行更多调试。

4

1 回答 1

4

对此,解决方案似乎微不足道。我在 google 的 ansible 组上找到了它。

只需要添加

sudo = true 
sudo_user = root

在 ansible.cfg 文件中。

至少这个错误消失了,但我遇到了新的错误。

编辑 正如下面评论中所建议的,sudo_user 必须是 root,因此,相应地更改了分析器。

于 2015-12-03T05:46:43.737 回答