问题原文
原帖链接 · Ask and Learn · CC BY-SA 3.0
I am trying to setup Ansible to manage Linux boxes from different customers and here are what we have to work with.
- No Pub key authentication - I wanted it as much as you do but it won't happen any time soon.
- We login as root and each customer has a different root password for all linux boxes. We are pushing for disable direct root login and do everything via
sudobut again, it will take some time.
I managed to create a ansible vault file for each customer with ansible_ssh_user and ansible_ssh_pass in it and following play-book works fine.
---
- hosts:
- SERV01
- SERV02
vars_files:
- roles/common/vault/main.yml
tasks:
- name: enable and start ntpd
service: name=ntpd enabled=yes state=running
Now I would like to know how can I use vault files from command line, but none of the following worked.
ansible customer1 -m shell -a "var_files:roles/common/vault/main.yml uptime" --ask-vault-pass
ansible customer1 -m shell -a "uptime" -e "vars_files:roles/common/vault/main.yml" --ask-vault-pass
What am I doing wrong ?
Thanks
已采纳解答
原帖链接 · Ask and Learn · CC BY-SA 3.0
Finally I found out how to do this:
ansible customer1 -e @group_vars/vault/customer1.yml --ask-vault-pass -m shell -a uptime
Now I can put ansible_ssh_user, ansible_ssh_pass and ansible_sudo_pass in a vault file and all I need to remember is the vault password.
I hope that makes Ansible more enjoyable for you as well.
Thanks
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
