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_args passed to all steps #2963

Closed
t2d opened this issue Nov 12, 2020 · 3 comments · Fixed by #2966
Closed

ansible_args passed to all steps #2963

t2d opened this issue Nov 12, 2020 · 3 comments · Fixed by #2966
Labels
Milestone

Comments

@t2d
Copy link
Contributor

t2d commented Nov 12, 2020

Issue Type

  • Bug report

Molecule and Ansible details

molecule 3.2.0a0
    ansible:2.9.7 python:3.8
    delegated:3.2.0a0 from molecule
    podman:0.3.0 from molecule_podman
    vagrant:0.5 from molecule_vagrant

Molecule installation method (one of):

  • pip

Ansible installation method (one of):

  • OS package

Desired Behavior

I have a particular use case where I want to test a full playbook and it's roles. However, the playbook has to be called with specified tags. I would call the playbook in production like this:

ansible-playbook site.yml -t install

Therefore, I configured my molecule.yml like this:

---
dependency:
  name: galaxy
driver:
  name: vagrant
platforms:
  - name: opensuse15
    box: generic/opensuse15
  - name: debian10
    box: generic/debian10
provisioner:
  name: ansible
  ansible_args:
   - --tags=install
  playbooks:
    converge: ../../site.yml
verifier:
  name: ansible

I would expect molecule to pass these parameters to the converge step only.

Actual Behaviour

Molecule passes the tags also to create and destroy, which makes my machines never start/stop.

A good create command looks like this

COMMAND: ansible-playbook --diff --inventory /home/t/.cache/molecule/playbook/default/inventory --skip-tags molecule-notest,notest /home/t/.local/lib/python3.8/site-packages/molecule_vagrant/playbooks/create.yml

With ansible_args it looks like that:

COMMAND: ansible-playbook --diff --inventory /home/t/.cache/molecule/playbook/default/inventory --skip-tags molecule-notest,notest --become --tags=install /home/t/.local/lib/python3.8/site-packages/molecule_default/playbooks/create.yml

The create playbook doesn't do anything with just this tag.

I have reprodiced this with both vagrant and podman driver.

@t2d t2d added the bug label Nov 12, 2020
@t2d
Copy link
Contributor Author

t2d commented Nov 12, 2020

My current workaround is to apply tags manually to the converge step, but i would like to avoid this

cat molecule.yml
---
dependency:
  name: galaxy
driver:
  name: vagrant
platforms:
  - name: opensuse15
    box: generic/opensuse15
  - name: debian10
    box: generic/debian10
provisioner:
  name: ansible
  playbooks:
    converge: ../../site.yml
verifier:
  name: ansible

molecule create
molecule converge -- -t install
molecule verify
molecule destroy

@t2d
Copy link
Contributor Author

t2d commented Nov 17, 2020

Thanks a lot!

@OlGe404
Copy link

OlGe404 commented Apr 23, 2022

For those who need to pass config options to all steps and found this issue searching for a solution: Use the config_options in the provisioner section of the molecule.yaml file.

I needed to pass a vault-keyring-script to all molecule steps and used ansible_args first, but as stated above that is not intended for this purpose.

Do it like this:

# molecule.yml
provisioner:
  name: ansible
  config_options:
    defaults:
      vault_identity_list: <identity>@<path-to-keyring-scrpt>

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

Successfully merging a pull request may close this issue.

3 participants