Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ansible/ansible-examples.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToshio Kuratomi <toshio@fedoraproject.org>2014-10-02 22:32:56 +0400
committerToshio Kuratomi <toshio@fedoraproject.org>2014-10-02 22:32:56 +0400
commit675fb88483b9d5279858724193dd52d4ebf92058 (patch)
tree31f830b94ceb7fb4f9a3a37b954daf5ec6753421 /language_features
parent59ba91f064195e6c5ab9a633a1d585c1857bd837 (diff)
Update examples for modern ansible and state that duplicating parameters causes an error.
Diffstat (limited to 'language_features')
-rw-r--r--language_features/complex_args.yml46
1 files changed, 22 insertions, 24 deletions
diff --git a/language_features/complex_args.yml b/language_features/complex_args.yml
index 3fdc954..ebbb1d9 100644
--- a/language_features/complex_args.yml
+++ b/language_features/complex_args.yml
@@ -2,27 +2,30 @@
# this is a bit of an advanced topic.
#
-# generally Ansible likes to pass simple key=value arguments to modules. It occasionally comes up though
-# that you might want to write a module that takes COMPLEX arguments, like lists and dictionaries.
+# generally Ansible likes to pass simple key=value arguments to modules. It
+# occasionally comes up though that you might want to write a module that takes
+# COMPLEX arguments, like lists and dictionaries.
#
-# happen, at least right now, it should be a Python module, so it can leverage some common code in Ansible that
-# makes this easy. If you write a non-Python module, you can still pass data across, but only hashes that
-# do not contain lists or other hashes. If you write the Python module, you can do anything.
+# In order for this to happen, at least right now, it should be a Python
+# module, so it can leverage some common code in Ansible that makes this easy.
+# If you write a non-Python module, you can still pass data across, but only
+# hashes that do not contain lists or other hashes. If you write the Python
+# module, you can do anything.
#
-# note that if you were to use BOTH the key=value form and the 'args' form for passing data in, the key=value
-# parameters take a higher priority, so you can use them for defaults, which can be useful.
+# note that if you were to use BOTH the key=value form and the 'args' form for
+# passing data in, the behaviour is currently undefined. Ansible is working to
+# standardize on returning a duplicate parameter failure in this case but
+# modules which don't use the common module framework may do something
+# different.
-- hosts: all
- user: root
+- hosts: localhost
gather_facts: no
-
+
vars:
- defaults:
- state: stopped
complex:
ghostbusters: [ 'egon', 'ray', 'peter', 'winston' ]
mice: [ 'pinky', 'brain', 'larry' ]
-
+
tasks:
- name: this is the basic way data passing works for any module
@@ -32,16 +35,11 @@
ping: data='Hi Mom'
- name: but what if you have a complex module that needs complicated data?
- action: ping
- args:
- data:
- moo: cow
- asdf: [1,2,3,4]
+ ping:
+ data:
+ moo: cow
+ asdf: [1,2,3,4]
- name: can we make that cleaner? sure!
- action: ping
- args: { data: "{{ complex }}" }
-
- - name: here is an example of how it works with defaults, notice the key=value format wins
- action: service name=httpd state=running
- args: defaults
+ ping:
+ data: "{{ complex }}"