I am quite new to Ansible and try to “make a tour”…
I am using ansible 2.4.2.0 with cygwin64 on Win7.
I am currently make a personal training and find that I could use a block to “enclose” (ok, perhaps wrong term) a couple of task that have some common “properties” (like become_user: root …).
The idea is to change this :
block does not support ALL the features of a simple task so this may be your issue. For example, it may not support notify, but you’ll need to look at this.
Thanks all for your help.
I have been really bored with the block… but I finally succeed. The ansible / yaml syntax is not always straightforward to understand (or I lack some skills).
I went back to the ansible block documentation, and make a trial replacing my main.yml file with the example on the page, i.e. :
And I still get an error saying that the role must contain a list of task :
`
ERROR! The tasks/main.yml file for role ‘devTools’ must contain a list of tasks
The error appears to have been in ‘/home/jeanlupi/centos_test/myKnowledge/devOps/playbook/roles/devTools/tasks/main.yml’: line 1, column 1, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
tasks:
^ here
`
Ok… I removed “tasks” (don’t clearly understand why it must not be there…) and the problem disappeared.
After several other syntax errors (probably not totally sticked to block), I succeeded with :