mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
more 0.8 documenting
This commit is contained in:
parent
63100c9bc0
commit
ca261e8961
1 changed files with 36 additions and 0 deletions
|
@ -254,6 +254,18 @@ there will be accessible to future tasks::
|
|||
action: site_facts
|
||||
- action: command echo ${my_custom_fact_can_be_used_now}
|
||||
|
||||
In Ansible 0.8, a few shortcuts are available for testing whether a variable is defined or not::
|
||||
|
||||
tasks:
|
||||
- action: command echo hi
|
||||
only_if: is_set($some_variable)
|
||||
|
||||
There is a matching 'is_unset' that works the same way. Do not quote the variables inside the function.
|
||||
|
||||
While only_if is a pretty good option for advanced users, it exposes more guts of the engine than we'd like, and
|
||||
we can do better. In 0.9, we will be adding 'when', which will be like a syntactic sugar for only_if and hide
|
||||
this level of complexity -- it will numerous built in operators.
|
||||
|
||||
Conditional Imports
|
||||
```````````````````
|
||||
|
||||
|
@ -329,6 +341,30 @@ The above would be the equivalent of::
|
|||
|
||||
The yum and apt modules use with_items to execute fewer package manager transactions.
|
||||
|
||||
More Loops
|
||||
``````````
|
||||
|
||||
.. versionadded: 0.8
|
||||
|
||||
Various 'lookup plugins' allow additional ways to iterate over data. Ansible will have more of these
|
||||
over time. In 0.8, the only lookup plugin that comes stock is 'with_fileglob', but you can also write
|
||||
your own.
|
||||
|
||||
'with_fileglob' matches all files in a single directory, non-recursively, that match a pattern. It can
|
||||
be used like this::
|
||||
|
||||
----
|
||||
- hosts: all
|
||||
|
||||
tasks:
|
||||
|
||||
# first ensure our target directory exists
|
||||
- file: dest=/etc/fooapp state=directory
|
||||
|
||||
# copy each file over that matches the given pattern
|
||||
- copy: src=$item dest=/etc/fooapp/ owner=root mode=600
|
||||
with_fileglob: /playbooks/files/fooapp/*
|
||||
|
||||
|
||||
Selecting Files And Templates Based On Variables
|
||||
````````````````````````````````````````````````
|
||||
|
|
Loading…
Reference in a new issue