mirror of
https://github.com/geerlingguy/ansible-role-apache
synced 2025-01-10 11:50:18 +01:00
45 lines
1.5 KiB
YAML
45 lines
1.5 KiB
YAML
---
|
|
|
|
# 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.
|
|
#
|
|
# 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 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: localhost
|
|
gather_facts: no
|
|
|
|
vars:
|
|
complex:
|
|
ghostbusters: [ 'egon', 'ray', 'peter', 'winston' ]
|
|
mice: [ 'pinky', 'brain', 'larry' ]
|
|
|
|
tasks:
|
|
|
|
- name: this is the basic way data passing works for any module
|
|
action: ping data='Hi Mom'
|
|
|
|
- name: of course this can also be written like so, which is shorter
|
|
ping: data='Hi Mom'
|
|
|
|
- name: but what if you have a complex module that needs complicated data?
|
|
ping:
|
|
data:
|
|
moo: cow
|
|
asdf: [1,2,3,4]
|
|
|
|
- name: can we make that cleaner? sure!
|
|
ping:
|
|
data: "{{ complex }}"
|