| Name |
Last commit
|
Last update |
|---|---|---|
| bin | ||
| docs/man | ||
| examples | ||
| hacking | ||
| lib/ansible | ||
| library | ||
| packaging | ||
| test | ||
| .gitignore | ||
| CHANGELOG.md | ||
| COPYING | ||
| MANIFEST.in | ||
| Makefile | ||
| README.md | ||
| RELEASES.txt | ||
| VERSION | ||
| setup.py |
The use-case here is that based on information in the /proc/cmdline certain actions can be taken.
A practical example in our case is that we have a play at the end of the provisioning phase that reboots the system. Since we don't want to accidentally reboot a system (or restart the network) on a production machine, having a way to separate an Anaconda post-install (sshd in chroot) with a normal system is a good way to make that distinction.
---
- name: reboot
hosts: all
tasks:
- action: command init 6
only_if: "not '${ansible_cmdline.BOOT_IMAGE}'.startswith('$')"
A practical problem here is the fact that we cannot simply check whether it is set or empty:
---
- name: reboot
hosts: all
tasks:
- action: command init 6
only_if: "'${ansible_cmdline.BOOT_IMAGE}'"
If ansible_cmdline was a string, a simple only_if: "'${ansible_cmdline}'.find(' BOOT_IMAGE=')" was an option, but still not very "beautiful" :-/
This implementation uses shlex.split() and uses split(sep, maxsplit=1).
| Name |
Last commit
|
Last update |
|---|---|---|
| bin | Loading commit data... | |
| docs/man | Loading commit data... | |
| examples | Loading commit data... | |
| hacking | Loading commit data... | |
| lib/ansible | Loading commit data... | |
| library | Loading commit data... | |
| packaging | Loading commit data... | |
| test | Loading commit data... | |
| .gitignore | Loading commit data... | |
| CHANGELOG.md | Loading commit data... | |
| COPYING | Loading commit data... | |
| MANIFEST.in | Loading commit data... | |
| Makefile | Loading commit data... | |
| README.md | Loading commit data... | |
| RELEASES.txt | Loading commit data... | |
| VERSION | Loading commit data... | |
| setup.py | Loading commit data... |