Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ansible provisioner using group_vars #19

Open
ghost opened this issue Apr 16, 2021 · 1 comment
Open

ansible provisioner using group_vars #19

ghost opened this issue Apr 16, 2021 · 1 comment

Comments

@ghost
Copy link

ghost commented Apr 16, 2021

This issue was originally opened by @jesusch as hashicorp/packer#9540. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.


I have multiple inventory files per environment:

ansible git:(master) ✗ ls hosts 
hosts.dev               hosts.old            hosts.prod              staging                
hosts.ds                hosts.poc           
hosts.inf            

any of those inventories has group_vars for e.g. frontend servers
my packer.json file looks like:

  "provisioners": [
    {
      "type": "ansible",
      "playbook_file": "packer/playbooks/frontend.yml",
      "groups": [ "frontends" ],
      "inventory_directory": "hosts/hosts.{{ user `env` }}",
      "extra_arguments": [
        "--ssh-extra-args", "-o IdentitiesOnly=yes"
      ]
    }
  ],

while running this task packer always creates a dynamic inventory which does not include my group_vars:

ansible-playbook -e ... -i hosts/hosts.preprev/packer-provisioner-ansible441481275 ..ansible/packer/playbooks/frontend.yml
How do I add already defined inventory variables to such a packer host?

@NicolasCARPi
Copy link

Hello,

In my hands this is no longer a problem so I guess this issue can be closed. Groups are correctly taken into account by the provisioner.

Cheers,
~Nico

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant