是否可以通过ansible剧本禁用Vault?

时间:2019-05-06 11:06:52

标签: testing ansible ansible-vault

出于自动化测试的目的,我想在执行ansible-playbook时禁用Vault,以便在测试中覆盖加密的变量。

我见过--ask-vault-pass,但不是相反,即--no-vault-pass之类。

ansible settings并未指定环境变量来这样做。

2 个答案:

答案 0 :(得分:1)

您可以为测试创建一个特殊的配置文件,其中故意排除了库信息,并告诉Ansible在运行测试剧本时使用此配置文件:

ANSIBLE_CONFIG=/my/special.cfg ansible-playbook testplaybook.yml

答案 1 :(得分:1)

也许您正在寻找按环境分离结构的方法,例如:

├── ansible.cfg               # check below.
├── inventories               # directory to group all hosts and variables.
│   ├── production            # "environment" directory as we discussed before.
│   │   ├── group_vars
│   │   │   ├── appserver
│   │   │   │   ├── vars.yml
│   │   │   │   └── vault.yml # encrypted sensitive data.
│   │   │   └── proxyserver
│   │   │       ├── vars.yml
│   │   │       └── vault.yml
│   │   └── inventory
│   ├── staging
│   │   ├── group_vars
│   │   │   ├── appserver
│   │   │   │   ├── vars.yml
│   │   │   │   └── vault.yml # encrypted sensitive data.
│   │   │   └── proxyserver
│   │   │       ├── vars.yml
│   │   │       └── vault.yml
│   │   └── inventory
│   └── development
│       ├── group_vars
│       │   ├── appserver
│       │   │   └── vars.yml  # no need to encrypt for local development.
│       │   └── proxyserver
│       │       └── vars.yml
│       └── inventory
├── site.yml
├── books                     # group all the playbooks under same directory.
│   ├── appserver.yml
│   └── proxyserver.yml
├── roles
│   └── app
└── roles.galaxy              # separate contributed roles
    └── author.proxy

继续此处: https://steyeu.co/posts/ansible-project-layout-for-multistage-environments-based-on-best-practice/#the-suggested-way