Last active
March 28, 2018 19:00
-
-
Save cuongnv23/fb77bae3b6b013eb8d60 to your computer and use it in GitHub Desktop.
Ansible - Insert to end of line with lineinfile module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #handlers/main.yml | |
| --- | |
| - name: Restart apache | |
| service: name=apache2 state=restarted enabled=yes | |
| tags: | |
| - apache | |
| #task/main.yml | |
| --- | |
| - name: Enable apache modules | |
| lineinfile: > | |
| dest="{{ apache_sysconfig }}" | |
| backrefs=true | |
| state=present | |
| regexp='^APACHE_MODULES=\"(.*(?<!{{ apache_en_modules }}))\"' | |
| line='APACHE_MODULES="\1 {{ apache_en_modules }}"' | |
| notify: | |
| - Restart apache | |
| tags: | |
| - apache | |
| - name: Add SSL to APACHE_SERVER_FLAGS | |
| lineinfile: > | |
| regexp='^APACHE_SERVER_FLAGS=\"(.*(?<!SSL))\"' | |
| line='APACHE_SERVER_FLAGS="\1 SSL"' | |
| dest="{{ apache_sysconfig }}" | |
| backrefs=true | |
| state=present | |
| notify: | |
| - Restart apache | |
| tags: | |
| - apache | |
| #vars/main.yml | |
| --- | |
| apache_sysconfig: "/etc/sysconfig/apache2" | |
| apache_en_modules: "proxy proxy_http rewrite headers" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment