mirror of https://github.com/ansible/ansible.git
Mirror of https://github.com/ansible/ansible.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Executive summary: skipping a host corrupts a variable (when it is registered)
We have a play existing out of multiple tasks that check a condition, if one of these tasks fails we want to skip all next tasks in the playbook. I noticed that if we skip a task because a certain condition is met, and this task has a register-attribute, I loose the value in the variable. Which means we cannot use that variable in subsequent tasks to evaluate because it was skipped:
```
- action: command test -d /some/directory
register: task
- action: command test -f /some/directory/file
register: task
only_if: '${task.rc} == 0'
- action: do something else
only_if: '${task.rc} == 0'
```
In the above example, if the second task is skipped (because the first failed), the third action will end with a "SyntaxError: invalid syntax" complaining about the unsubstituted ${task.rc} (even though it was set by the first task and used for skipping the second).
The following play demonstrates the problem:
```
- name: Test register on ignored tasks
hosts: all
gather_facts: no
vars:
skip: true
task: { 'rc': 666 }
tasks:
- action: debug msg='skip = ${skip}, task.rc = ${task.rc}'
- name: Skip this task, just to test if task has changed
action: command ls
register: task
only_if: '${skip} != True'
- action: debug msg='skip = ${skip}, task.rc = ${task.rc}'
- name: Now use task value
action: command echo 'Works !'
only_if: '${task.rc} == 0'
```
And the enclosed fix, fixes the above problem.
|
13 years ago | |
|---|---|---|
| bin | 13 years ago | |
| docs/man | 13 years ago | |
| docsite | 13 years ago | |
| examples | 13 years ago | |
| hacking | 13 years ago | |
| lib/ansible | 13 years ago | |
| library | 13 years ago | |
| packaging | 13 years ago | |
| plugins | 13 years ago | |
| test | 13 years ago | |
| .gitignore | 13 years ago | |
| CHANGELOG.md | 13 years ago | |
| CONTRIBUTING.md | 13 years ago | |
| COPYING | 14 years ago | |
| MANIFEST.in | 14 years ago | |
| Makefile | 13 years ago | |
| README.md | 13 years ago | |
| RELEASES.txt | 13 years ago | |
| VERSION | 13 years ago | |
| setup.py | 13 years ago | |
README.md
Ansible
Ansible is a radically simple configuration-management, deployment, task-execution, and multinode orchestration framework.
Read the documentation and more at http://ansible.cc
Design Principles
- Dead simple setup
- Super fast & parallel by default
- No server or client daemons; use existing SSHd
- No additional software required on client boxes
- Modules can be written in ANY language
- Awesome API for creating very powerful distributed scripts
- Be usable as non-root
- The easiest config management system to use, ever.
Get Involved
- ansible-project mailing list
- irc.freenode.net: #ansible
Branch Info
- Releases are named after Van Halen songs.
- The devel branch corresponds to the release actively under development.
- Various release-X.Y branches exist for previous releases
- We'd love to have your contributions, read "CONTRIBUTING.md" for process notes.
Author
Michael DeHaan -- michael.dehaan@gmail.com