vars_files cannot see register variables or variables set in group_vars, but can see one set from the command line when import_playbook used (v2.4)

19 views
Skip to first unread message

Pa S

unread,
Aug 10, 2017, 2:19:09 PM8/10/17
to Ansible Project
Hello:

I'm trying to dynamically set which vault I'm using (don't want my test environment to use real passwords!).

So I set up this in a play book that I'm doing an import_playbook from a different directory.

If vault_file is set from the ansible-playbook command line, this works. If I set the vault_file from a group vars file from the calling playbook's dir, vault_file doesn't exist from for the vars_files a statement's viewpoint.  If I set it in a fact vault_file also doesn't exist from the vars_files viewpoint.

But oddly enough, if I debug vault_file in the debug role, it prints out correctly in all three cases.

Bug, or feature?  And how do I work around this?

---

#

# Sets up Docker networks

#

- name: Setup the networks

  hosts: dockerhosts

  vars_files:

     - demoVars.yml

     - "{{ vault_file }}"

  roles:

    - role: debug

    - role: network_setup

      options:

        internal: "{{ networks.internal }}"

        external: "{{ networks.external }}"

        nginx: "{{ networks.nginx }}"

  tags:

    - setup

    - standalone

    - app_test



---- importing file ----


- name: create facts used to compose variables later in this playbook

  hosts: dockerhosts

  vars:

    esTmpDir: "/tmp/es"

  roles:

    - role: unitenv_setup

  tags:

    - app_test


- import_playbook: ../../../deployment/playbooks/network.yml


Reply all
Reply to author
Forward
0 new messages