diff options
author | Sam Doran <sdoran@ansible.com> | 2016-10-12 16:26:24 -0400 |
---|---|---|
committer | Sam Doran <sdoran@ansible.com> | 2016-11-14 14:12:43 -0500 |
commit | 942eb37a5427835a87bf2ae884f278073ccb57aa (patch) | |
tree | ce061dee319499fd0b4d1f4139b105b96ac8f903 | |
parent | 83f42ecfd4784f4555055da4e4b5bd2bbcb04d1b (diff) | |
download | ansible-modules-core-942eb37a5427835a87bf2ae884f278073ccb57aa.tar.gz |
Change examples syntax on lineinfile module
-rw-r--r-- | files/lineinfile.py | 63 |
1 files changed, 49 insertions, 14 deletions
diff --git a/files/lineinfile.py b/files/lineinfile.py index 045827f7..4b6088c2 100644 --- a/files/lineinfile.py +++ b/files/lineinfile.py @@ -120,26 +120,61 @@ options: """ EXAMPLES = r""" -- lineinfile: dest=/etc/selinux/config regexp=^SELINUX= line=SELINUX=enforcing - -- lineinfile: dest=/etc/sudoers state=absent regexp="^%wheel" - -- lineinfile: dest=/etc/hosts regexp='^127\.0\.0\.1' line='127.0.0.1 localhost' owner=root group=root mode=0644 - -- lineinfile: dest=/etc/httpd/conf/httpd.conf regexp="^Listen " insertafter="^#Listen " line="Listen 8080" - -- lineinfile: dest=/etc/services regexp="^# port for http" insertbefore="^www.*80/tcp" line="# port for http by default" +- lineinfile: + dest: /etc/selinux/config + regexp: '^SELINUX=' + line: 'SELINUX=enforcing' + +- lineinfile: + dest: /etc/sudoers + state: absent + regexp: '^%wheel' + +- lineinfile: + dest: /etc/hosts + regexp: '^127\.0\.0\.1' + line: '127.0.0.1 localhost' + owner: root + group: root + mode: 0644 + +- lineinfile: + dest: /etc/httpd/conf/httpd.conf + regexp: '^Listen ' + insertafter: '^#Listen ' + line: 'Listen 8080' + +- lineinfile: + dest: /etc/services + regexp: '^# port for http' + insertbefore: '^www.*80/tcp' + line: '# port for http by default' # Add a line to a file if it does not exist, without passing regexp -- lineinfile: dest=/tmp/testfile line="192.168.1.99 foo.lab.net foo" +- lineinfile: + dest: /tmp/testfile + line: '192.168.1.99 foo.lab.net foo' # Fully quoted because of the ': ' on the line. See the Gotchas in the YAML docs. -- lineinfile: "dest=/etc/sudoers state=present regexp='^%wheel' line='%wheel ALL=(ALL) NOPASSWD: ALL'" - -- lineinfile: dest=/opt/jboss-as/bin/standalone.conf regexp='^(.*)Xms(\d+)m(.*)$' line='\1Xms${xms}m\3' backrefs=yes +- lineinfile: " + dest: /etc/sudoers + state: present + regexp: '^%wheel' + line: '%wheel ALL=(ALL) NOPASSWD: ALL' + +- lineinfile: + dest: /opt/jboss-as/bin/standalone.conf + regexp: '^(.*)Xms(\d+)m(.*)$' + line: '\1Xms${xms}m\3' + backrefs: yes # Validate the sudoers file before saving -- lineinfile: dest=/etc/sudoers state=present regexp='^%ADMIN ALL\=' line='%ADMIN ALL=(ALL) NOPASSWD:ALL' validate='visudo -cf %s' +- lineinfile: + dest: /etc/sudoers + state: present + regexp: '^%ADMIN ALL=' + line: '%ADMIN ALL=(ALL) NOPASSWD: ALL' + validate: 'visudo -cf %s' """ import re |