大网数据广告活动
服务器运维问答

Ansible command line retriving ssh password from vault

· 52CE 我爱测

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…

问题原文

原帖链接 · 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.

  1. No Pub key authentication - I wanted it as much as you do but it won't happen any time soon.
  2. 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 sudo but 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

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2015-04-29)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。