mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-02 14:40:19 -07:00
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
This commit is contained in:
parent
ad6999e2eb
commit
b56a9852ee
20 changed files with 261 additions and 87 deletions
|
@ -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
|
||||
'''
|
||||
|
|
|
@ -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"
|
||||
'''
|
||||
|
|
|
@ -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
|
||||
"""
|
||||
|
|
|
@ -59,7 +59,8 @@ notes:
|
|||
'''
|
||||
|
||||
EXAMPLES = """
|
||||
- include_role: name=myrole
|
||||
- include_role:
|
||||
name: myrole
|
||||
|
||||
- name: Run tasks/other.yml instead of 'main'
|
||||
include_role:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
'''
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue