- name: "Dokku Plugins: Install"
become: true
command: "dokku plugin:install https://github.com/dokku/dokku-{{ item }}.git"
args:
creates: "/var/lib/dokku/plugins/available/{{ item }}/*"
register: dokku_plugin_install
changed_when: dokku_plugin_install.stdout|search('Plugin ' + item + ' enabled')
tags:
- dokku_install_plugin
with_items:
- mysql
- letsencrypt
- maintenance
Hopefully pretty straight-forward on what I'm trying to solve. The quick explanation is I'm installing some plugins in Dokku using the command "dokku plugin:install" and providing it with a loop of items. Then to check whether it is already installed, I search stdout.
In this case, I may have gotten away with searching for "enabled." But I lean towards being explicit so I'm clear in what's going on. Ultimately, I'd like to release this on Galaxy for people to use. So I'd like to make it clear what it is that I'm doing in my tasks.
However, as I continue to build out my roles and tasks, I may not always have the option to do avoid using variables.
While my use case is a bit different from Rich's use case, I think what it comes down to for both of us is lack of clarity and consistency in how the Jinja templates work.
Hi All,Am new to this group and Google Groups in general so please go easy.I have a few questions about the recent change in Ansible 2.3.0.0 that new prints a warning when jinja2 templating is included in a when, changed_when and failed_when statement. Please see this closed GitHub issue for more details on exactly what warning I mean: https://github.com/ansible/ansible/issues/22397
---
- name: Install Red Hat Security Advisory (RHSA)
command: yum -y update-minimal --advisory {{ rhsa_to_install }}
register: yum_output
- debug: var=yum_output
- name: Reboot Host if any packages were updated
shell: sleep 2 && shutdown -r now "Ansible updates triggered"
async: 1
poll: 0
ignore_errors: true
when: ("Complete!" in "{{ yum_output.stdout_lines[-1] }}") or
("Komplett!" in "{{ yum_output.stdout_lines[-1] }}")
There are just 2 contexts, normal (you require them) and conditionals
(anything with when:) which don't. It is consistent, juts not uniform.
$ cat inventoryone ansible_connection=local$ cat play.yml---- hosts: alltasks:- debug:msg: "{{ item.message }}"when: "{{ item.condition }}"with_items:- { message: "hello", condition: "7 < 4" }- { message: "goodbye", condition: "7 > 4" }$ ansible-playbook -i inventory play.ymlPLAY [all] *******************************************************************************TASK [Gathering Facts] *******************************************************************ok: [one]TASK [debug] *****************************************************************************[WARNING]: when statements should not include jinja2 templating delimiters such as {{ }}or {% %}. Found: {{ item.condition }}ok: [one] => (item={u'message': u'goodbye', u'condition': u'7 > 4'}) => {"item": {"condition": "7 > 4","message": "goodbye"},"msg": "goodbye"}skipping: [one] => (item={u'message': u'hello', u'condition': u'7 < 4'})PLAY RECAP *******************************************************************************one : ok=2 changed=0 unreachable=0 failed=0$