summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Doran <sdoran@ansible.com>2016-11-15 15:21:47 -0500
committerJohn R Barker <john@johnrbarker.com>2016-11-15 20:21:47 +0000
commit05e866e4d01e3b9c2893e0a3dbb053cb7311dcd1 (patch)
tree48c62747e974e56135ad404a9ae0344eabf4baef
parent109c68980424146121d79e4bc91cec475894645a (diff)
downloadansible-modules-core-05e866e4d01e3b9c2893e0a3dbb053cb7311dcd1.tar.gz
Examples syntax batch4 (#5620)
* Change example syntax on authorized_key module * Change example syntax on cron module * Change example syntax on group module * Change example syntax on hostname module * Change example syntax on seboolean module * Change example syntax on selinux module * Change example syntax on service module * Change example syntax on sysctl module * Change example syntax on systemd module * Change example syntax on user module * Change example syntax on debug module * Change example syntax on fail module * Change example syntax on include module * Change example syntax on include_role module * Change example syntax on include_vars module * Change example syntax on pause module * Change example syntax on wait_for module * Change example syntax on apache2_module module * > Change example syntax on django_manage module * Change example syntax on htpasswd module
-rw-r--r--system/authorized_key.py12
-rw-r--r--system/cron.py47
-rw-r--r--system/group.py6
-rw-r--r--system/hostname.py3
-rw-r--r--system/seboolean.py5
-rw-r--r--system/selinux.py16
-rw-r--r--system/service.py30
-rw-r--r--system/sysctl.py24
-rw-r--r--system/systemd.py22
-rw-r--r--system/user.py31
-rw-r--r--utilities/logic/debug.py16
-rw-r--r--utilities/logic/fail.py3
-rw-r--r--utilities/logic/include.py17
-rw-r--r--utilities/logic/include_role.py3
-rw-r--r--utilities/logic/include_vars.py10
-rw-r--r--utilities/logic/pause.py6
-rw-r--r--utilities/logic/wait_for.py38
-rw-r--r--web_infrastructure/apache2_module.py8
-rw-r--r--web_infrastructure/django_manage.py30
-rw-r--r--web_infrastructure/htpasswd.py21
20 files changed, 261 insertions, 87 deletions
diff --git a/system/authorized_key.py b/system/authorized_key.py
index 0b15d2fd..6cfd856e 100644
--- a/system/authorized_key.py
+++ b/system/authorized_key.py
@@ -99,18 +99,20 @@ EXAMPLES = '''
# Using github url as key source
- authorized_key:
user: charlie
- key: https://github.com/charlie.keys
+ key: 'https://github.com/charlie.keys'
# Using alternate directory locations:
- authorized_key:
user: charlie
key: "{{ lookup('file', '/home/charlie/.ssh/id_rsa.pub') }}"
- path: '/etc/ssh/authorized_keys/charlie'
+ path: /etc/ssh/authorized_keys/charlie
manage_dir: no
# Using with_file
- name: Set up authorized_keys for the deploy user
- authorized_key: user=deploy key="{{ item }}"
+ authorized_key:
+ user: deploy
+ key: "{{ item }}"
with_file:
- public_keys/doe-jane
- public_keys/doe-john
@@ -124,13 +126,13 @@ EXAMPLES = '''
# Using validate_certs:
- authorized_key:
user: charlie
- key: https://github.com/user.keys
+ key: 'https://github.com/user.keys'
validate_certs: no
# Set up authorized_keys exclusively with one key
- authorized_key:
user: root
- key: '{{ item }}'
+ key: "{{ item }}"
state: present
exclusive: yes
with_file:
diff --git a/system/cron.py b/system/cron.py
index 2ab23ef6..9dd5b5c9 100644
--- a/system/cron.py
+++ b/system/cron.py
@@ -171,32 +171,59 @@ author:
EXAMPLES = '''
# Ensure a job that runs at 2 and 5 exists.
# Creates an entry like "0 5,2 * * ls -alh > /dev/null"
-- cron: name="check dirs" minute="0" hour="5,2" job="ls -alh > /dev/null"
+- cron:
+ name: "check dirs"
+ minute: "0"
+ hour: "5,2"
+ job: "ls -alh > /dev/null"
# Ensure an old job is no longer present. Removes any job that is prefixed
# by "#Ansible: an old job" from the crontab
-- cron: name="an old job" state=absent
+- cron:
+ name: "an old job"
+ state: absent
# Creates an entry like "@reboot /some/job.sh"
-- cron: name="a job for reboot" special_time=reboot job="/some/job.sh"
+- cron:
+ name: "a job for reboot"
+ special_time: reboot
+ job: "/some/job.sh"
# Creates an entry like "PATH=/opt/bin" on top of crontab
-- cron: name=PATH env=yes value=/opt/bin
+- cron:
+ name: PATH
+ env: yes
+ value: /opt/bin
# Creates an entry like "APP_HOME=/srv/app" and insert it after PATH
# declaration
-- cron: name=APP_HOME env=yes value=/srv/app insertafter=PATH
+- cron:
+ name: APP_HOME
+ env: yes
+ value: /srv/app
+ insertafter: PATH
# Creates a cron file under /etc/cron.d
-- cron: name="yum autoupdate" weekday="2" minute=0 hour=12
- user="root" job="YUMINTERACTIVE=0 /usr/sbin/yum-autoupdate"
- cron_file=ansible_yum-autoupdate
+- cron:
+ name: yum autoupdate
+ weekday: 2
+ minute: 0
+ hour: 12
+ user: root
+ job: "YUMINTERACTIVE: 0 /usr/sbin/yum-autoupdate"
+ cron_file: ansible_yum-autoupdate
# Removes a cron file from under /etc/cron.d
-- cron: name="yum autoupdate" cron_file=ansible_yum-autoupdate state=absent
+- cron:
+ name: "yum autoupdate"
+ cron_file: ansible_yum-autoupdate
+ state: absent
# Removes "APP_HOME" environment variable from crontab
-- cron: name=APP_HOME env=yes state=absent
+- cron:
+ name: APP_HOME
+ env: yes
+ state: absent
'''
import os
diff --git a/system/group.py b/system/group.py
index efff0f2e..ceffd753 100644
--- a/system/group.py
+++ b/system/group.py
@@ -53,7 +53,9 @@ options:
EXAMPLES = '''
# Example group command from Ansible Playbooks
-- group: name=somegroup state=present
+- group:
+ name: somegroup
+ state: present
'''
import grp
@@ -144,7 +146,7 @@ class SunOS(Group):
This overrides the following methods from the generic class:-
- group_add()
- """
+ """
platform = 'SunOS'
distribution = None
diff --git a/system/hostname.py b/system/hostname.py
index 4c4285f6..92fd6758 100644
--- a/system/hostname.py
+++ b/system/hostname.py
@@ -40,7 +40,8 @@ options:
'''
EXAMPLES = '''
-- hostname: name=web01
+- hostname:
+ name: web01
'''
import socket
diff --git a/system/seboolean.py b/system/seboolean.py
index 4581c133..973b5b2d 100644
--- a/system/seboolean.py
+++ b/system/seboolean.py
@@ -50,7 +50,10 @@ author: "Stephen Fromm (@sfromm)"
EXAMPLES = '''
# Set (httpd_can_network_connect) flag on and keep it persistent across reboots
-- seboolean: name=httpd_can_network_connect state=yes persistent=yes
+- seboolean:
+ name: httpd_can_network_connect
+ state: yes
+ persistent: yes
'''
try:
diff --git a/system/selinux.py b/system/selinux.py
index 2debb95a..2afd4756 100644
--- a/system/selinux.py
+++ b/system/selinux.py
@@ -49,9 +49,19 @@ author: "Derek Carter (@goozbach) <goozbach@friocorte.com>"
'''
EXAMPLES = '''
-- selinux: policy=targeted state=enforcing
-- selinux: policy=targeted state=permissive
-- selinux: state=disabled
+# Enable SELinux
+- selinux:
+ policy: targeted
+ state: enforcing
+
+# Put SELinux in permissive mode, logging actions that would be blocked.
+- selinux:
+ policy: targeted
+ state: permissive
+
+# Disable SELinux
+- selinux:
+ state: disabled
'''
import os
diff --git a/system/service.py b/system/service.py
index c8781b1c..1da88f0e 100644
--- a/system/service.py
+++ b/system/service.py
@@ -78,25 +78,41 @@ options:
EXAMPLES = '''
# Example action to start service httpd, if not running
-- service: name=httpd state=started
+- service:
+ name: httpd
+ state: started
# Example action to stop service httpd, if running
-- service: name=httpd state=stopped
+- service:
+ name: httpd
+ state: stopped
# Example action to restart service httpd, in all cases
-- service: name=httpd state=restarted
+- service:
+ name: httpd
+ state: restarted
# Example action to reload service httpd, in all cases
-- service: name=httpd state=reloaded
+- service:
+ name: httpd
+ state: reloaded
# Example action to enable service httpd, and not touch the running state
-- service: name=httpd enabled=yes
+- service:
+ name: httpd
+ enabled: yes
# Example action to start service foo, based on running process /usr/bin/foo
-- service: name=foo pattern=/usr/bin/foo state=started
+- service:
+ name: foo
+ pattern: /usr/bin/foo
+ state: started
# Example action to restart network service for interface eth0
-- service: name=network state=restarted args=eth0
+- service:
+ name: network
+ state: restarted
+ args: eth0
'''
diff --git a/system/sysctl.py b/system/sysctl.py
index 3df8e1fe..9a6787e2 100644
--- a/system/sysctl.py
+++ b/system/sysctl.py
@@ -76,25 +76,37 @@ author: "David CHANIAL (@davixx) <david.chanial@gmail.com>"
EXAMPLES = '''
# Set vm.swappiness to 5 in /etc/sysctl.conf
-- sysctl:
- name: vm.swappiness
+- sysctl:
+ name: vm.swappiness
value: 5
state: present
# Remove kernel.panic entry from /etc/sysctl.conf
- sysctl:
name: kernel.panic
- state: absent
+ state: absent
sysctl_file: /etc/sysctl.conf
# Set kernel.panic to 3 in /tmp/test_sysctl.conf
-- sysctl: name=kernel.panic value=3 sysctl_file=/tmp/test_sysctl.conf reload=no
+- sysctl:
+ name: kernel.panic
+ value: 3
+ sysctl_file: /tmp/test_sysctl.conf
+ reload: no
# Set ip forwarding on in /proc and do not reload the sysctl file
-- sysctl: name="net.ipv4.ip_forward" value=1 sysctl_set=yes
+- sysctl:
+ name: net.ipv4.ip_forward
+ value: 1
+ sysctl_set: yes
# Set ip forwarding on in /proc and in the sysctl file and reload if necessary
-- sysctl: name="net.ipv4.ip_forward" value=1 sysctl_set=yes state=present reload=yes
+- sysctl:
+ name: net.ipv4.ip_forward
+ value: 1
+ sysctl_set: yes
+ state: present
+ reload: yes
'''
# ==============================================================
diff --git a/system/systemd.py b/system/systemd.py
index fdaeae64..4c170916 100644
--- a/system/systemd.py
+++ b/system/systemd.py
@@ -72,18 +72,32 @@ requirements:
EXAMPLES = '''
# Example action to start service httpd, if not running
-- systemd: state=started name=httpd
+- systemd:
+ state: started
+ name: httpd
+
# Example action to stop service cron on debian, if running
-- systemd: name=cron state=stopped
+- systemd:
+ name: cron
+ state: stopped
+
# Example action to restart service cron on centos, in all cases, also issue daemon-reload to pick up config changes
-- systemd: state=restarted daemon_reload=yes name=crond
+- systemd:
+ state: restarted
+ daemon_reload: yes
+ name: crond
+
# Example action to reload service httpd, in all cases
-- systemd: name=httpd state=reloaded
+- systemd:
+ name: httpd
+ state: reloaded
+
# Example action to enable service httpd and ensure it is not masked
- systemd:
name: httpd
enabled: yes
masked: no
+
# Example action to enable a timer for dnf-automatic
- systemd:
name: dnf-automatic.timer
diff --git a/system/user.py b/system/user.py
index c424beea..b67f9620 100644
--- a/system/user.py
+++ b/system/user.py
@@ -160,7 +160,7 @@ options:
default: rsa
version_added: "0.9"
description:
- - Optionally specify the type of SSH key to generate.
+ - Optionally specify the type of SSH key to generate.
Available SSH key types will depend on implementation
present on target host.
ssh_key_file:
@@ -201,19 +201,38 @@ options:
EXAMPLES = '''
# Add the user 'johnd' with a specific uid and a primary group of 'admin'
-- user: name=johnd comment="John Doe" uid=1040 group=admin
+- user:
+ name: johnd
+ comment: "John Doe"
+ uid: 1040
+ group: admin
# Add the user 'james' with a bash shell, appending the group 'admins' and 'developers' to the user's groups
-- user: name=james shell=/bin/bash groups=admins,developers append=yes
+- user:
+ name: james
+ shell: /bin/bash
+ groups: admins,developers
+ append: yes
# Remove the user 'johnd'
-- user: name=johnd state=absent remove=yes
+- user:
+ name: johnd
+ state: absent
+ remove: yes
# Create a 2048-bit SSH key for user jsmith in ~jsmith/.ssh/id_rsa
-- user: name=jsmith generate_ssh_key=yes ssh_key_bits=2048 ssh_key_file=.ssh/id_rsa
+- user:
+ name: jsmith
+ generate_ssh_key: yes
+ ssh_key_bits: 2048
+ ssh_key_file: .ssh/id_rsa
# added a consultant whose account you want to expire
-- user: name=james18 shell=/bin/zsh groups=developers expires=1422403387
+- user:
+ name: james18
+ shell: /bin/zsh
+ groups: developers
+ expires: 1422403387
'''
import os
diff --git a/utilities/logic/debug.py b/utilities/logic/debug.py
index 89d9254a..f28dc538 100644
--- a/utilities/logic/debug.py
+++ b/utilities/logic/debug.py
@@ -44,23 +44,29 @@ options:
required: False
default: 0
version_added: "2.1"
-author:
+author:
- "Dag Wieers (@dagwieers)"
- "Michael DeHaan"
'''
EXAMPLES = '''
# Example that prints the loopback address and gateway for each host
-- debug: msg="System {{ inventory_hostname }} has uuid {{ ansible_product_uuid }}"
+- debug:
+ msg: "System {{ inventory_hostname }} has uuid {{ ansible_product_uuid }}"
-- debug: msg="System {{ inventory_hostname }} has gateway {{ ansible_default_ipv4.gateway }}"
+- debug:
+ msg: "System {{ inventory_hostname }} has gateway {{ ansible_default_ipv4.gateway }}"
when: ansible_default_ipv4.gateway is defined
- shell: /usr/bin/uptime
register: result
-- debug: var=result verbosity=2
+- debug:
+ var: result
+ verbosity: 2
- name: Display all variables/facts known for a host
- debug: var=hostvars[inventory_hostname] verbosity=4
+ debug:
+ var: hostvars[inventory_hostname]
+ verbosity: 4
'''
diff --git a/utilities/logic/fail.py b/utilities/logic/fail.py
index 75a7c81d..0957b597 100644
--- a/utilities/logic/fail.py
+++ b/utilities/logic/fail.py
@@ -39,6 +39,7 @@ author: "Dag Wieers (@dagwieers)"
EXAMPLES = '''
# Example playbook using fail and when together
-- fail: msg="The system may not be provisioned according to the CMDB status."
+- fail:
+ msg: "The system may not be provisioned according to the CMDB status."
when: cmdb_status != "to-be-staged"
'''
diff --git a/utilities/logic/include.py b/utilities/logic/include.py
index bdca4298..e5c2face 100644
--- a/utilities/logic/include.py
+++ b/utilities/logic/include.py
@@ -34,7 +34,8 @@ EXAMPLES = """
# include a play after another play
- hosts: localhost
tasks:
- - debug: msg="play1"
+ - debug:
+ msg: "play1"
- include: otherplays.yml
@@ -42,15 +43,21 @@ EXAMPLES = """
# include task list in play
- hosts: all
tasks:
- - debug: msg=task1
+ - debug:
+ msg: task1
+
- include: stuff.yml
- - debug: msg=task10
+
+ - debug:
+ msg: task10
# dyanmic include task list in play
- hosts: all
tasks:
- - debug: msg=task1
- - include: {{hostvar}}.yml
+ - debug:
+ msg: task1
+
+ - include: "{{ hostvar }}.yml"
static: no
when: hostvar is defined
"""
diff --git a/utilities/logic/include_role.py b/utilities/logic/include_role.py
index 2ddbc623..40208764 100644
--- a/utilities/logic/include_role.py
+++ b/utilities/logic/include_role.py
@@ -59,7 +59,8 @@ notes:
'''
EXAMPLES = """
-- include_role: name=myrole
+- include_role:
+ name: myrole
- name: Run tasks/other.yml instead of 'main'
include_role:
diff --git a/utilities/logic/include_vars.py b/utilities/logic/include_vars.py
index 87747bb7..571ddf58 100644
--- a/utilities/logic/include_vars.py
+++ b/utilities/logic/include_vars.py
@@ -61,15 +61,17 @@ EXAMPLES = """
name: stuff
# Conditionally decide to load in variables into 'plans' when x is 0, otherwise do not. (2.2)
-- include_vars: file=contingency_plan.yml name=plans
+- include_vars:
+ file: contingency_plan.yml
+ name: plans
when: x == 0
# Load a variable file based on the OS type, or a default if not found.
- include_vars: "{{ item }}"
with_first_found:
- - "{{ ansible_distribution }}.yml"
- - "{{ ansible_os_family }}.yml"
- - "default.yml"
+ - "{{ ansible_distribution }}.yml"
+ - "{{ ansible_os_family }}.yml"
+ - "default.yml"
# bare include (free-form)
- include_vars: myvars.yml
diff --git a/utilities/logic/pause.py b/utilities/logic/pause.py
index 75d2db1a..5290a632 100644
--- a/utilities/logic/pause.py
+++ b/utilities/logic/pause.py
@@ -47,11 +47,13 @@ notes:
EXAMPLES = '''
# Pause for 5 minutes to build app cache.
-- pause: minutes=5
+- pause:
+ minutes: 5
# Pause until you can verify updates to an application were successful.
- pause:
# A helpful reminder of what to look out for post-update.
-- pause: prompt="Make sure org.foo.FooOverload exception is not present"
+- pause:
+ prompt: "Make sure org.foo.FooOverload exception is not present"
'''
diff --git a/utilities/logic/wait_for.py b/utilities/logic/wait_for.py
index d57d18d7..2cd99c24 100644
--- a/utilities/logic/wait_for.py
+++ b/utilities/logic/wait_for.py
@@ -123,30 +123,50 @@ author:
EXAMPLES = '''
# wait 300 seconds for port 8000 to become open on the host, don't start checking for 10 seconds
-- wait_for: port=8000 delay=10
+- wait_for:
+ port: 8000
+ delay: 10
# wait 300 seconds for port 8000 of any IP to close active connections, don't start checking for 10 seconds
-- wait_for: host=0.0.0.0 port=8000 delay=10 state=drained
+- wait_for:
+ host: 0.0.0.0
+ port: 8000
+ delay: 10
+ state: drained
# wait 300 seconds for port 8000 of any IP to close active connections, ignoring connections for specified hosts
-- wait_for: host=0.0.0.0 port=8000 state=drained exclude_hosts=10.2.1.2,10.2.1.3
+- wait_for:
+ host: 0.0.0.0
+ port: 8000
+ state: drained
+ exclude_hosts: 10.2.1.2,10.2.1.3
# wait until the file /tmp/foo is present before continuing
-- wait_for: path=/tmp/foo
+- wait_for:
+ path: /tmp/foo
# wait until the string "completed" is in the file /tmp/foo before continuing
-- wait_for: path=/tmp/foo search_regex=completed
+- wait_for:
+ path: /tmp/foo
+ search_regex: completed
# wait until the lock file is removed
-- wait_for: path=/var/lock/file.lock state=absent
+- wait_for:
+ path: /var/lock/file.lock
+ state: absent
# wait until the process is finished and pid was destroyed
-- wait_for: path=/proc/3466/status state=absent
+- wait_for:
+ path: /proc/3466/status
+ state: absent
# wait 300 seconds for port 22 to become open and contain "OpenSSH", don't assume the inventory_hostname is resolvable
# and don't start checking for 10 seconds
-- local_action: wait_for port=22 host="{{ ansible_ssh_host | default(inventory_hostname) }}" search_regex=OpenSSH delay=10
-
+- local_action: wait_for
+ port: 22
+ host: "{{ ansible_ssh_host | default(inventory_hostname) }}"
+ search_regex: OpenSSH
+ delay: 10
'''
class TCPConnectionInfo(object):
diff --git a/web_infrastructure/apache2_module.py b/web_infrastructure/apache2_module.py
index 9f9df923..2e5060d3 100644
--- a/web_infrastructure/apache2_module.py
+++ b/web_infrastructure/apache2_module.py
@@ -47,10 +47,14 @@ requirements: ["a2enmod","a2dismod"]
EXAMPLES = '''
# enables the Apache2 module "wsgi"
-- apache2_module: state=present name=wsgi
+- apache2_module:
+ state: present
+ name: wsgi
# disables the Apache2 module "wsgi"
-- apache2_module: state=absent name=wsgi
+- apache2_module:
+ state: absent
+ name: wsgi
'''
import re
diff --git a/web_infrastructure/django_manage.py b/web_infrastructure/django_manage.py
index 3ce815dc..f334f398 100644
--- a/web_infrastructure/django_manage.py
+++ b/web_infrastructure/django_manage.py
@@ -99,24 +99,34 @@ author: "Scott Anderson (@tastychutney)"
EXAMPLES = """
# Run cleanup on the application installed in 'django_dir'.
-- django_manage: command=cleanup app_path={{ django_dir }}
+- django_manage:
+ command: cleanup
+ app_path: "{{ django_dir }}"
# Load the initial_data fixture into the application
-- django_manage: command=loaddata app_path={{ django_dir }} fixtures={{ initial_data }}
+- django_manage:
+ command: loaddata
+ app_path: "{{ django_dir }}"
+ fixtures: "{{ initial_data }}"
# Run syncdb on the application
-- django_manage: >
- command=syncdb
- app_path={{ django_dir }}
- settings={{ settings_app_name }}
- pythonpath={{ settings_dir }}
- virtualenv={{ virtualenv_dir }}
+- django_manage:
+ command: syncdb
+ app_path: "{{ django_dir }}"
+ settings: "{{ settings_app_name }}"
+ pythonpath: "{{ settings_dir }}"
+ virtualenv: "{{ virtualenv_dir }}"
# Run the SmokeTest test case from the main app. Useful for testing deploys.
-- django_manage: command=test app_path={{ django_dir }} apps=main.SmokeTest
+- django_manage:
+ command: test
+ app_path: "{{ django_dir }}"
+ apps: main.SmokeTest
# Create an initial superuser.
-- django_manage: command="createsuperuser --noinput --username=admin --email=admin@example.com" app_path={{ django_dir }}
+- django_manage:
+ command: "createsuperuser --noinput --username=admin --email=admin@example.com"
+ app_path: "{{ django_dir }}"
"""
diff --git a/web_infrastructure/htpasswd.py b/web_infrastructure/htpasswd.py
index f1a4e482..84a2cbdd 100644
--- a/web_infrastructure/htpasswd.py
+++ b/web_infrastructure/htpasswd.py
@@ -74,11 +74,26 @@ author: "Ansible Core Team"
EXAMPLES = """
# Add a user to a password file and ensure permissions are set
-- htpasswd: path=/etc/nginx/passwdfile name=janedoe password=9s36?;fyNp owner=root group=www-data mode=0640
+- htpasswd:
+ path: /etc/nginx/passwdfile
+ name: janedoe
+ password: '9s36?;fyNp'
+ owner: root
+ group: www-data
+ mode: 0640
+
# Remove a user from a password file
-- htpasswd: path=/etc/apache2/passwdfile name=foobar state=absent
+- htpasswd:
+ path: /etc/apache2/passwdfile
+ name: foobar
+ state: absent
+
# Add a user to a password file suitable for use by libpam-pwdfile
-- htpasswd: path=/etc/mail/passwords name=alex password=oedu2eGh crypt_scheme=md5_crypt
+- htpasswd:
+ path: /etc/mail/passwords
+ name: alex
+ password: oedu2eGh
+ crypt_scheme: md5_crypt
"""