我想使用ansible vault加密我的ansible库存文件,因为它包含IP /密码/密钥文件路径等,我不想将其保持为可读格式。
这就是我的尝试。
我的文件夹结构如下所示
env/
hosts
hosts_details
plays/
test.yml
files/
vault_pass.txt
ENV /主机
[server-a]
server-a-name
[server-b]
server-b-name
[webserver:children]
server-a
server-b
env / hosts_details(我要加密的文件)
[server-a:vars]
env_name=server-a
ansible_ssh_user=root
ansible_ssh_host=10.0.0.1
ansible_ssh_private_key_file=~/.ssh/xyz-key.pem
[server-b:vars]
env_name=server-b
ansible_ssh_user=root
ansible_ssh_host=10.0.0.2
ansible_ssh_private_key_file=~/.ssh/xyz-key.pem
test.yml
---
- hosts: webserver
tasks:
- name: Print Hello world
debug:
msg: "Hello World"
无加密执行成功运行,没有任何错误
ansible-playbook -i env/ test.yml
当我使用files / vault_pass.txt中的vault文件加密我的env / hosts_details文件,然后执行playbook时出现以下错误
ansible-playbook -i env/ test.yml --vault-password-file files/vault_pass.txt
PLAY [webserver]
******************************************************************
TASK [setup]
*******************************************************************
Thursday 10 August 2017 11:21:01 +0100 (0:00:00.053) 0:00:00.053 *******
fatal: [server-a-name]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: Could not resolve hostname server-a-name: Name or service not known\r\n", "unreachable": true}
fatal: [server-b-name]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: Could not resolve hostname server-b-name: Name or service not known\r\n", "unreachable": true}
PLAY RECAP
*********************************************************************
server-a-name : ok=0 changed=0 unreachable=1 failed=0
server-b-name : ok=0 changed=0 unreachable=1 failed=0
我想知道我是否遗漏了任何内容,或者是否可以加密库存文件。
还有其他替代品吗?