Created
March 5, 2015 12:04
-
-
Save komeda-shinji/0ac2d7866e01b23aaf48 to your computer and use it in GitHub Desktop.
Ansibleで設定ファイルの行を書き換える(コンテキスト編) ref: http://qiita.com/komeda-shinji/items/e24fab2ab0f2f5858111
This file contains 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
- hosts: servers | |
vars: | |
httpd_conf: /etc/apache2/apache2.conf | |
tasks: | |
- name: lookup DocumentRoot in VirtualHost | |
shell: sed -n '/^<VirtualHost \*:80>/,/<\/VirtualHost>/{/DocumentRoot/p; }' {{httpd_conf}} | |
register: lookup | |
changed_when: False | |
- name: change httpd.conf | |
shell: sed -i$(date +'.%Y-%m-%d@%H:%M~') '/^<VirtualHost \*:80>/,/<\/VirtualHost>/{s/\(DocumentRoot[[:space:]]*\).*$/\1\/var\/www/; }' {{httpd_conf}} | |
when: lookup.stdout != "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment