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

Task to fail if ansible_min_version isn't met #130

Conversation

gundalow
Copy link
Contributor

@gundalow gundalow commented Aug 7, 2018

At somepoint the Roles will use Ansible features that are only in certain releases, ensure that the end user is running the correct version of Ansible.

Read ansible_min_version from meta/main.yml and fail the playbook if
that version of Ansible (or higher) isn't being used.

Use fail, rather than assert to avoid noisy error message.

Ansible 2.5

TASK [ansible-network.network-engine : read ansible_min_version from meta data] **************************************************************************
ok: [localhost]

TASK [ansible-network.network-engine : validate minimum Ansible version] *********************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "This role requires Ansible 2.6 or higher. You are currently running Ansible 2.5.2."}

PLAY RECAP ***********************************************************************************************************************************************
localhost                  : ok=2    changed=0    unreachable=0    failed=1   

Ansible 2.6

TASK [ansible-network.network-engine : read ansible_min_version from meta data] ***
ok: [localhost]

TASK [ansible-network.network-engine : validate minimum Ansible version] *******
skipping: [localhost]

TASK [ansible-network.network-engine : validate connection is network_cli] *****

... Play continues

Read ansible_min_version from meta/main.yml and fail the playbook if
that version of Ansible (or higher) isn't being used.

Use `fail`, rather than `assert` to avoid noisy error message.
@gundalow
Copy link
Contributor Author

gundalow commented Aug 7, 2018

If we are happy with this we should backport into stable-2.5

@softwarefactory-project-zuul

This comment has been minimized.

@softwarefactory-project-zuul

This comment has been minimized.

tasks/cli.yaml Outdated
@@ -1,4 +1,14 @@
---
- name: read ansible_min_version from meta data
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this go into a dedicated tasks/validate.yaml which all other tasks include?

Copy link
Member

@trishnaguha trishnaguha Aug 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gundalow see #131. You can add this validation in main.yaml instead as it is entrypoint, so it will run for plugins and modules also.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a slightly different pattern that makes this work a little more seamlessly within the roles. Take a look at the following two links:

https://github.com/ansible-network/arista_eos/blob/devel/tasks/load_config.yaml#L3
https://github.com/ansible-network/arista_eos/blob/devel/includes/init.yaml

The above pattern creates an init set of tasks where we can centrally handle all role validation instead of having to manage individual ones and make sure they are propagated to every role, every time.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@gundalow

This comment has been minimized.

@gundalow

This comment has been minimized.

@softwarefactory-project-zuul

This comment has been minimized.

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

@gundalow gundalow added the gate Gate PR in Zuul CI label Aug 15, 2018
@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded (gate pipeline).

@softwarefactory-project-zuul softwarefactory-project-zuul bot merged commit 1f4351f into ansible-network:devel Aug 15, 2018
@gundalow gundalow deleted the ansible_min_version_check branch August 16, 2018 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gate Gate PR in Zuul CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants