Hi Anand
You actually can (and I prefer to) write your playbooks with that kind of plain YAML syntax. e.g.
- hosts: localhost
tasks:
- name: blah
yum:
name:
- mypackage
- otherpackage
state: present
- name: blurh
copy:
src: myfile
dest: /tmp/myfile
mode: 0640
owner: me
It gets more interesting with the shell and command modules
- hosts: localhost
tasks:
- name: run this
shell: mycommand
args:
creates: /tmp/artefact
chdir: /path/to/dir
executable: /bin/bash
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/34adf7d7-5d32-459d-a3a3-8fe02d049271%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/dGJRlrohfmY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAAnNz0NnD0x08r0ODROxGEf8sQtFFKKe2ACVux6EXysgvC7uzQ%40mail.gmail.com.
--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/dGJRlrohfmY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAAnNz0NnD0x08r0ODROxGEf8sQtFFKKe2ACVux6EXysgvC7uzQ%40mail.gmail.com.
--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/dGJRlrohfmY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/1422871831.2610733.221884249.32774E87%40webmail.messagingengine.com.
Hi Anand
Are you sure your indenting is correct? Here’s an example from one of my role task files, known working with Ansible v1.8.2 (packages trimmed for brevity)
---
- name: Install packages (apt)
apt:
pkg:
- bash-completion
- bind9utils
- vim-nox
- zsh
state: present
when: ansible_os_family == 'Debian'
- name: Install packages (yum)
yum:
name:
- bind-utils
- byobu
- vim-enhanced
- zsh
state: present
when: ansible_os_family == 'RedHat'
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CANbPJFn3ZbnsGfm05q1ZqCYPtpOQGyzPL9qTumhgOGhgcezZHw%40mail.gmail.com.
Jinja templating doesn’t work in playbooks in that way. Lots of variable constructs are actually parsed with jinja2, so you can do stuff like
- set_fact:
myvar: "{% if something %}this{% else %}that{% endif %}"
As Giovanni mentioned, there are numerous looping constructs for things like task repetition. Playbooks are declarative, so it wouldn’t really be right to build them from a template.
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CANbPJFn3ZbnsGfm05q1ZqCYPtpOQGyzPL9qTumhgOGhgcezZHw%40mail.gmail.com.
---
- name: install packages
yum:
name:
- screen
- tmux
- lsof
state: present
ansible 1.8.2
configured module search path = None
As an Ansible newbie, I have struggled with understanding where it's
Ansible or Jinja2 doing the parsing. So I can surely related to that. On
the other hand, Ansible tries to be simple and the looping constructs,
IMHO, are easy to work with and have a concise syntax.
Jinja templating doesn’t work in playbooks in that way. Lots of variable constructs are actually parsed with jinja2, so you can do stuff like
- set_fact: myvar: "{% if something %}this{% else %}that{% endif %}"
As Giovanni mentioned, there are numerous looping constructs for things like task repetition. Playbooks are declarative, so it wouldn’t really be right to build them from a template.