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

Deprecation warnings #134

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

davidpanofsky
Copy link

use check_mode instead of always_run because of deprecation

@awailly
Copy link
Owner

awailly commented Mar 9, 2017

Any clue why Travis is showing the following error?

ERROR: check_mode is not a legal parameter in an Ansible task or handler

@pchaigno
Copy link
Collaborator

pchaigno commented Mar 9, 2017

I think it was added in Ansible 2.2. If we use that, we'll have to drop support for 1.9 and 2.0.

@awailly
Copy link
Owner

awailly commented Mar 9, 2017

@pchaigno, can you think of a fancy way to support all versions?

@donovan
Copy link

donovan commented Mar 9, 2017

This is the same issue as #122. I hit it when moving to 2.1 or 2.2. I don't know of a good way to support all versions.

@donovan
Copy link

donovan commented Mar 9, 2017

I tried a couple of things that did not work:

#!/usr/bin/env ansible-playbook
---

- name: Test always run / check_mode
  hosts: localhost

  tasks:
    - name: Test false 1
      command: /bin/false
      register: false_result
      changed_when: false_result.rc == 0
      failed_when: false_result.rc != 0 and false_result.rc != 1
      always_run: True
      when: "{{ ansible_version < 2.2 }}"

    - name: Test false 2
      command: /bin/false
      register: false_result
      changed_when: false_result.rc == 0
      failed_when: false_result.rc != 0 and false_result.rc != 1
      check_mode: no
      when: "{{ ansible_version > 2.1 }}"

    - name: Test false 3
      command: /bin/false
      register: false_result
      changed_when: false_result.rc == 0
      failed_when: false_result.rc != 0 and false_result.rc != 1
      check_mode: no '{{ (ansible_version > 2.1) | ternary("value",omit) }}'
      always_run: True '{{ (ansible_version < 2.2) | ternary("value",omit) }}'

result with ansible 2.2.0.0:

PLAY [Test always run / check_mode] ********************************************

TASK [setup] *******************************************************************
Friday 10 March 2017  11:37:09 +1300 (0:00:00.019)       0:00:00.019 ********** 
ok: [localhost]

TASK [Test false 1] ************************************************************
Friday 10 March 2017  11:37:12 +1300 (0:00:03.277)       0:00:03.297 ********** 
[DEPRECATION WARNING]: always_run is deprecated. Use check_mode = no instead..
This feature will be removed in version 2.4. Deprecation warnings can be disabled by setting deprecation_warnings=False in 
ansible.cfg.
skipping: [localhost]

TASK [Test false 2] ************************************************************
Friday 10 March 2017  11:37:13 +1300 (0:00:00.032)       0:00:03.329 ********** 
ok: [localhost]

TASK [Test false 3] ************************************************************
Friday 10 March 2017  11:37:13 +1300 (0:00:00.206)       0:00:03.536 ********** 
[DEPRECATION WARNING]: always_run is deprecated. Use check_mode = no instead..
This feature will be removed in version 2.4. Deprecation warnings can be disabled by setting deprecation_warnings=False in 
ansible.cfg.
ok: [localhost]

PLAY RECAP *********************************************************************
localhost                  : ok=3    changed=0    unreachable=0    failed=0

@pchaigno
Copy link
Collaborator

We could probably write our own module to backport check_mode to Ansible < 2.2.0, but I doubt it's worth it. Ansible 2.2.0 is still pretty new (end of 2016), so maybe we should wait 2.3.0 before dropping support for Ansible < 2.2.0?

@awailly
Copy link
Owner

awailly commented Mar 10, 2017

I concur. @donovan, do you think it's OK to wait until 2.3.0 to move towards check_mode ?

@donovan
Copy link

donovan commented Mar 10, 2017

Should be OK yes, people who have already moved to 2.2 can do what I did and patch their local copy if they want to get rid of the warnings.

@pchaigno
Copy link
Collaborator

pchaigno commented Oct 3, 2017

Ansible 2.4 is out, we really need to revisit this.

@donovan Could you update your branch to remove Ansible 2.0 and 1.9.1 from the .travis.yml file and add Ansible 2.1, 2.2, 2.3, and 2.4?

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

Successfully merging this pull request may close these issues.

4 participants