Fix read vaulted toml inventory (#54226) (#54235)

This commit is contained in:
咚咔
2019-04-10 22:10:48 +08:00
committed by Matt Martz
parent 54384e7a12
commit 72fc11ff13
4 changed files with 27 additions and 3 deletions

View File

@@ -0,0 +1,5 @@
[vauled_group.hosts]
vaulted_host_toml={ ansible_host="localhost", ansible_connection="local" }
[vauled_group.vars]
hello="world"

View File

@@ -1,6 +1,8 @@
#!/usr/bin/env bash
set -euvx
source virtualenv.sh
MYTMPDIR=$(mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir')
trap 'rm -rf "${MYTMPDIR}"' EXIT
@@ -404,6 +406,14 @@ ansible-playbook test_vault_embedded.yml -i ../../inventory -v "$@" --vault-pass
ansible-playbook test_vaulted_inventory.yml -i vaulted.inventory -v "$@" --vault-password-file vault-password
ansible-playbook test_vaulted_template.yml -i ../../inventory -v "$@" --vault-password-file vault-password
# install TOML for parse toml inventory
# test playbooks using vaulted files(toml)
pip install toml
ansible-vault encrypt ./inventory.toml -v "$@" --vault-password-file=./vault-password
ansible-playbook test_vaulted_inventory_toml.yml -i ./inventory.toml -v "$@" --vault-password-file vault-password
ansible-vault decrypt ./inventory.toml -v "$@" --vault-password-file=./vault-password
# test a playbook with a host_var whose value is non-ascii utf8 (see https://github.com/ansible/ansible/issues/37258)
ansible-playbook -i ../../inventory -v "$@" --vault-id vault-password test_vaulted_utf8_value.yml

View File

@@ -0,0 +1,9 @@
- hosts: vaulted_host_toml
gather_facts: no
tasks:
- name: See if we knew vaulted_host_toml
debug: msg="Found vaulted_host from vaulted.inventory.toml"
- assert:
that:
- 'hello=="world"'