mirror of
https://github.com/geerlingguy/ansible-role-apache
synced 2025-01-10 11:50:18 +01:00
Update examples for modern ansible and state that duplicating parameters causes an error.
This commit is contained in:
parent
59ba91f064
commit
675fb88483
1 changed files with 22 additions and 24 deletions
|
@ -2,23 +2,26 @@
|
||||||
|
|
||||||
# this is a bit of an advanced topic.
|
# this is a bit of an advanced topic.
|
||||||
#
|
#
|
||||||
# generally Ansible likes to pass simple key=value arguments to modules. It occasionally comes up though
|
# generally Ansible likes to pass simple key=value arguments to modules. It
|
||||||
# that you might want to write a module that takes COMPLEX arguments, like lists and dictionaries.
|
# 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
|
# In order for this to happen, at least right now, it should be a Python
|
||||||
# makes this easy. If you write a non-Python module, you can still pass data across, but only hashes that
|
# module, so it can leverage some common code in Ansible that makes this easy.
|
||||||
# do not contain lists or other hashes. If you write the Python module, you can do anything.
|
# 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
|
# note that if you were to use BOTH the key=value form and the 'args' form for
|
||||||
# parameters take a higher priority, so you can use them for defaults, which can be useful.
|
# 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
|
- hosts: localhost
|
||||||
user: root
|
|
||||||
gather_facts: no
|
gather_facts: no
|
||||||
|
|
||||||
vars:
|
vars:
|
||||||
defaults:
|
|
||||||
state: stopped
|
|
||||||
complex:
|
complex:
|
||||||
ghostbusters: [ 'egon', 'ray', 'peter', 'winston' ]
|
ghostbusters: [ 'egon', 'ray', 'peter', 'winston' ]
|
||||||
mice: [ 'pinky', 'brain', 'larry' ]
|
mice: [ 'pinky', 'brain', 'larry' ]
|
||||||
|
@ -32,16 +35,11 @@
|
||||||
ping: data='Hi Mom'
|
ping: data='Hi Mom'
|
||||||
|
|
||||||
- name: but what if you have a complex module that needs complicated data?
|
- name: but what if you have a complex module that needs complicated data?
|
||||||
action: ping
|
ping:
|
||||||
args:
|
data:
|
||||||
data:
|
moo: cow
|
||||||
moo: cow
|
asdf: [1,2,3,4]
|
||||||
asdf: [1,2,3,4]
|
|
||||||
|
|
||||||
- name: can we make that cleaner? sure!
|
- name: can we make that cleaner? sure!
|
||||||
action: ping
|
ping:
|
||||||
args: { data: "{{ complex }}" }
|
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
|
|
||||||
|
|
Loading…
Reference in a new issue