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

required_if functionality broken #20762

Closed
Harosgr opened this Issue Jan 27, 2017 · 2 comments

Comments

Projects
None yet
5 participants
@Harosgr

Harosgr commented Jan 27, 2017

ISSUE TYPE
  • Bug Report
COMPONENT NAME

module_utils/basic.py

ANSIBLE VERSION
ansible 2.2.1.0
OS / ENVIRONMENT

N/A

SUMMARY

It seems that the required_if functionality is broken. Execution continues even though the required_if criteria are not met.

STEPS TO REPRODUCE

For example the "mount" module uses the required_if

        required_if=(
            ['state', 'mounted', ['src', 'fstype']],
            ['state', 'present', ['src', 'fstype']]
        )

We can try to run the module with state present but without any src or fstype defined

- hosts: localhost
  tasks:
    - name: Just a test
      mount:
        state: present
        path: /mnt/foo
EXPECTED RESULTS

Get a message that the src or fstype arguments are required before proceeding to the actual execution

ACTUAL RESULTS

Execution continues

@Lujeni

This comment has been minimized.

Show comment
Hide comment
@Lujeni

Lujeni Mar 10, 2017

Contributor

Hello @Harosgr , @s-hertel

On the current version (devel) the bug is fixed (more details below).

This commit seems fixed your bug.

# bad
✘-127 ~/works/repos/perso/ansible/issue_20762 
15:49 $ ansible-playbook -i localhost, -c local test.yaml

PLAY [test mount] **************************************************************

TASK [setup] *******************************************************************
ok: [localhost]

TASK [install] *****************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "unsupported parameter for module: path"}
	to retry, use: --limit @/home/julien/works/repos/perso/ansible/issue_20762/test.retry

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

✘-2 ~/works/repos/perso/ansible/issue_20762 
15:49 $ ansible-playbook --version
ansible-playbook 2.2.1.0
  config file = 
  configured module search path = Default w/o overrides
✔ ~/works/repos/perso/ansible/issue_20762 
15:51 $ 

# good on devel
✘-2 ~/works/repos/perso/ansible/issue_20762 
15:48 $ ansible-playbook -i localhost, -c local test.yaml

PLAY [test mount] **************************************************************

TASK [setup] *******************************************************************
ok: [localhost]

TASK [install] *****************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "state is present but the following are missing: src,fstype"}
	to retry, use: --limit @/home/julien/works/repos/perso/ansible/issue_20762/test.retry

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

Lujeni commented Mar 10, 2017

Hello @Harosgr , @s-hertel

On the current version (devel) the bug is fixed (more details below).

This commit seems fixed your bug.

# bad
✘-127 ~/works/repos/perso/ansible/issue_20762 
15:49 $ ansible-playbook -i localhost, -c local test.yaml

PLAY [test mount] **************************************************************

TASK [setup] *******************************************************************
ok: [localhost]

TASK [install] *****************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "unsupported parameter for module: path"}
	to retry, use: --limit @/home/julien/works/repos/perso/ansible/issue_20762/test.retry

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

✘-2 ~/works/repos/perso/ansible/issue_20762 
15:49 $ ansible-playbook --version
ansible-playbook 2.2.1.0
  config file = 
  configured module search path = Default w/o overrides
✔ ~/works/repos/perso/ansible/issue_20762 
15:51 $ 

# good on devel
✘-2 ~/works/repos/perso/ansible/issue_20762 
15:48 $ ansible-playbook -i localhost, -c local test.yaml

PLAY [test mount] **************************************************************

TASK [setup] *******************************************************************
ok: [localhost]

TASK [install] *****************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "state is present but the following are missing: src,fstype"}
	to retry, use: --limit @/home/julien/works/repos/perso/ansible/issue_20762/test.retry

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

This comment has been minimized.

Show comment
Hide comment
@Akasurde

Akasurde Jan 16, 2018

Member

Closing this issue as this works on both 2.4 and latest devel (2.5). If issue persists, please feel free to re-open.

Member

Akasurde commented Jan 16, 2018

Closing this issue as this works on both 2.4 and latest devel (2.5). If issue persists, please feel free to re-open.

@Akasurde Akasurde closed this Jan 16, 2018

@ansibot ansibot added bug and removed bug_report labels Mar 7, 2018

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