-
Notifications
You must be signed in to change notification settings - Fork 48
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 playbook does not run on dynamic added host #94
Comments
Can you post the playbook you are trying to run? |
I'm experiencing the same behaviour, I suppose that - since you cannot set the For example with this
Ansible should read the private key from the dynamic inventory, but it fails (not only the private key is wrong, but also the user, it clearly doesn't read the right inventory)
|
I need to rebuild my environment, but it is like shown above |
If there are additional connection variables needed, you will have to set those on the playbook resource. |
I need those variables to apply to the targeted host only, applied to the playbook they mess up with any connection to localhost. |
any updates on this issue |
Ended up using provisioner local-exec in a terraform_data resource block for both the dynamic inventory creation and the playbook. |
did you use something like below or if you have any different config, could you please suggest. Thank you
|
I use dynamic inventory. And I think null_resource has been deprecated in favor of terraform_data:
|
Do I understand correctly that it is currently impossible to use "ansible_playbook" resource with aws_ec2 plugin? |
@mando-intelcom What do you think about adding an example in the repository from a MR? |
Trying to get a simple sample running for a playbook.
It looks like the playbook is not picking up the dynamic inventory. When I execute the playbook without the terraform , direct with ansible it works, if I trigger it through the ansible provider it seems as if the standard inventory is used.
[WARNING]: Could not match supplied host pattern, ignoring: myhosts\nansible-playbook [core 2.16.3]\n config file = None\n configured module search path = ['/Users/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']\n ansible python module location = /opt/homebrew/Cellar/ansible/9.2.0/libexec/lib/python3.12/site-packages/ansible\n ansible collection location = /Users/user/.ansible/collections:/usr/share/ansible/collections\n executable location = /opt/homebrew/bin/ansible-playbook\n python version = 3.12.2 (main, Feb 6 2024, 20:19:44) [Clang 15.0.0 (clang-1500.1.0.2.5)] (/opt/homebrew/Cellar/ansible/9.2.0/libexec/bin/python)\n jinja version = 3.1.3\n libyaml = True\nNo config file found; using defaults\nsetting up inventory plugins\nLoading collection ansible.builtin from \nhost_list declined parsing /var/folders/nl/bvl07_9s5djgkv2jc_41gj3r0000gn/T/.inventory-2409761638.ini as it did not pass its verify_file() method\nscript declined parsing /var/folders/nl/bvl07_9s5djgkv2jc_41gj3r0000gn/T/.inventory-2409761638.ini as it did not pass its verify_file() method\nauto declined parsing /var/folders/nl/bvl07_9s5djgkv2jc_41gj3r0000gn/T/.inventory-2409761638.ini as it did not pass its verify_file() method\nyaml declined parsing /var/folders/nl/bvl07_9s5djgkv2jc_41gj3r0000gn/T/.inventory-2409761638.ini as it did not pass its verify_file() method\nParsed /var/folders/nl/bvl07_9s5djgkv2jc_41gj3r0000gn/T/.inventory-2409761638.ini inventory source with ini plugin\nLoading callback plugin default of type stdout, v2.0 from /opt/homebrew/Cellar/ansible/9.2.0/libexec/lib/python3.12/site-packages/ansible/plugins/callback/default.py\nAttempting to use 'default' callback.\nSkipping callback 'default', as we already have a stdout callback.\nAttempting to use 'junit' callback.\nAttempting to use 'minimal' callback.\nSkipping callback 'minimal', as we already have a stdout callback.\nAttempting to use 'oneline' callback.\nSkipping callback 'oneline', as we already have a stdout callback.\nAttempting to use 'tree' callback.\n\nPLAYBOOK: playbook.yml *********************************************************\nPositional arguments: ./ansible/playbook.yml\nverbosity: 6\nconnection: ssh\nbecome_method: sudo\ntags: ('all',)\ncheck: True\ninventory: ('/var/folders/nl/bvl07_9s5djgkv2jc_41gj3r0000gn/T/.inventory-2409761638.ini',)\nextra_vars: ('hostname=myIP', 'var_b=Another variable', 'var_a=Some variable')\nforks: 5\n1 plays in ./ansible/playbook.yml\n\nPLAY [My first play] ***********************************************************\nskipping: no hosts matched\n\nPLAY RECAP *********************************************************************\n\n",
The text was updated successfully, but these errors were encountered: