diff --git a/lib/ansible/modules/system/authorized_key.py b/lib/ansible/modules/system/authorized_key.py index 0b15d2fd0a3..6cfd856e9a3 100644 --- a/lib/ansible/modules/system/authorized_key.py +++ b/lib/ansible/modules/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/lib/ansible/modules/system/cron.py b/lib/ansible/modules/system/cron.py index 99fe48366ac..e3571a0a904 100644 --- a/lib/ansible/modules/system/cron.py +++ b/lib/ansible/modules/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/lib/ansible/modules/system/group.py b/lib/ansible/modules/system/group.py index efff0f2e3dd..ceffd75369b 100755 --- a/lib/ansible/modules/system/group.py +++ b/lib/ansible/modules/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/lib/ansible/modules/system/hostname.py b/lib/ansible/modules/system/hostname.py index 4c4285f665f..92fd6758c58 100644 --- a/lib/ansible/modules/system/hostname.py +++ b/lib/ansible/modules/system/hostname.py @@ -40,7 +40,8 @@ options: ''' EXAMPLES = ''' -- hostname: name=web01 +- hostname: + name: web01 ''' import socket diff --git a/lib/ansible/modules/system/seboolean.py b/lib/ansible/modules/system/seboolean.py index 4581c1333ef..973b5b2d20b 100644 --- a/lib/ansible/modules/system/seboolean.py +++ b/lib/ansible/modules/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/lib/ansible/modules/system/selinux.py b/lib/ansible/modules/system/selinux.py index 2debb95a475..2afd47566aa 100644 --- a/lib/ansible/modules/system/selinux.py +++ b/lib/ansible/modules/system/selinux.py @@ -49,9 +49,19 @@ author: "Derek Carter (@goozbach) " ''' 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/lib/ansible/modules/system/service.py b/lib/ansible/modules/system/service.py index c8781b1c912..1da88f0ef34 100644 --- a/lib/ansible/modules/system/service.py +++ b/lib/ansible/modules/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/lib/ansible/modules/system/sysctl.py b/lib/ansible/modules/system/sysctl.py index 3df8e1fef88..9a6787e2a7e 100644 --- a/lib/ansible/modules/system/sysctl.py +++ b/lib/ansible/modules/system/sysctl.py @@ -76,25 +76,37 @@ author: "David CHANIAL (@davixx) " 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/lib/ansible/modules/system/systemd.py b/lib/ansible/modules/system/systemd.py index fdaeae64708..4c170916614 100644 --- a/lib/ansible/modules/system/systemd.py +++ b/lib/ansible/modules/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/lib/ansible/modules/system/user.py b/lib/ansible/modules/system/user.py index 272acd5678b..09a9cf9101f 100644 --- a/lib/ansible/modules/system/user.py +++ b/lib/ansible/modules/system/user.py @@ -159,7 +159,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: @@ -200,19 +200,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/lib/ansible/modules/utilities/logic/debug.py b/lib/ansible/modules/utilities/logic/debug.py index 89d9254a08e..f28dc538337 100644 --- a/lib/ansible/modules/utilities/logic/debug.py +++ b/lib/ansible/modules/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/lib/ansible/modules/utilities/logic/fail.py b/lib/ansible/modules/utilities/logic/fail.py index 75a7c81d1cf..0957b597184 100644 --- a/lib/ansible/modules/utilities/logic/fail.py +++ b/lib/ansible/modules/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/lib/ansible/modules/utilities/logic/include.py b/lib/ansible/modules/utilities/logic/include.py index bdca4298bdd..e5c2face7cf 100644 --- a/lib/ansible/modules/utilities/logic/include.py +++ b/lib/ansible/modules/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/lib/ansible/modules/utilities/logic/include_role.py b/lib/ansible/modules/utilities/logic/include_role.py index 2ddbc62355c..40208764a6f 100644 --- a/lib/ansible/modules/utilities/logic/include_role.py +++ b/lib/ansible/modules/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/lib/ansible/modules/utilities/logic/include_vars.py b/lib/ansible/modules/utilities/logic/include_vars.py index 87747bb7e3b..571ddf58e9f 100644 --- a/lib/ansible/modules/utilities/logic/include_vars.py +++ b/lib/ansible/modules/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/lib/ansible/modules/utilities/logic/pause.py b/lib/ansible/modules/utilities/logic/pause.py index 75d2db1a73a..5290a632230 100644 --- a/lib/ansible/modules/utilities/logic/pause.py +++ b/lib/ansible/modules/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/lib/ansible/modules/utilities/logic/wait_for.py b/lib/ansible/modules/utilities/logic/wait_for.py index d57d18d7b92..2cd99c24a1f 100644 --- a/lib/ansible/modules/utilities/logic/wait_for.py +++ b/lib/ansible/modules/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/lib/ansible/modules/web_infrastructure/apache2_module.py b/lib/ansible/modules/web_infrastructure/apache2_module.py index 9f9df923e03..2e5060d3a54 100644 --- a/lib/ansible/modules/web_infrastructure/apache2_module.py +++ b/lib/ansible/modules/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/lib/ansible/modules/web_infrastructure/django_manage.py b/lib/ansible/modules/web_infrastructure/django_manage.py index 3ce815dc582..f334f3989b2 100644 --- a/lib/ansible/modules/web_infrastructure/django_manage.py +++ b/lib/ansible/modules/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/lib/ansible/modules/web_infrastructure/htpasswd.py b/lib/ansible/modules/web_infrastructure/htpasswd.py index f1a4e482f3a..84a2cbdd29c 100644 --- a/lib/ansible/modules/web_infrastructure/htpasswd.py +++ b/lib/ansible/modules/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 """