On 19.10.2017 11:29, 'Tom Bartsch' via Ansible Project wrote:
> Hi there,
>
> could someone translate me the following playbook into python language?
I don't understand why you would need that, it's just a loop that print
thing out the the condition are met.
But since I'm in a process to learn Python why not.
> ---
> - hosts: "{{ host }}"
>
> vars:
> static_jobs:
> - templatename: "template1"
> templateextension: "zip"
> templateversion: "1.0.0"
> - templatename: "template2"
> templateextension: "zip"
> templateversion: "2.0.0"
> - templatename: "template3"
> templateextension: "war"
> templateversion: "4.5.0"
>
> tasks:
> - name: will not start message
> debug: "msg='{{ item.templatename }} und dann {{
> item.templateextension }} und am Ende {{ item.templateversion }} ...'"
> with_items: "{{ static_jobs }}"
> when: item.templateversion == "2.0.0"
>
static_jobs = [
{"templatename": "template1", "templateextension": "zip",
"templateversion": "1.0.0"},
{"templatename": "template2", "templateextension": "zip",
"templateversion": "2.0.0"},
{"templatename": "template3", "templateextension": "war",
"templateversion": "4.5.0"}
]
for item in static_jobs:
if item["templateversion"] == "2.0.0":
print item["templatename"] + " und dann " +
item["templateextension"] + " und am Ende " + item["templateversion"] +
"\n"
--
Kai Stian Olstad