ansible初心者なので、改善点とかありましたら教えてください
intall-httpd-playbook.yml
- hosts: [web-server]
vars:
src_dir: '/usr/local/src'
pcre_version: "8.33"
pcre_name: "pcre-$pcre_version"
pcre_dl_url: "ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/$pcre_name.tar.gz"
httpd_version: "2.4.6"
httpd_name: "httpd-$httpd_version"
httpd_dl_url: "http://ftp.jaist.ac.jp/pub/apache/httpd/httpd-$httpd_version.tar.gz"
apache_name: "apache-$httpd_version"
apr_version: "1.4.8"
apr_name: "apr-$apr_version"
apr_dl_url: "http://ftp.yz.yamagata-u.ac.jp/pub/network/apache/apr/apr-$apr_version.tar.gz"
apr_util_version: "1.5.2"
apr_util_name: "apr-util-$apr_util_version"
apr_util_dl_url: http://ftp.kddilabs.jp/infosystems/apache//apr/$apr_util_name.tar.gz
tasks:
- name: "make build dir"
file: dest=$src_dir state=directory
- name: "wget the pcre"
get_url: url=$pcre_dl_url dest=$src_dir
- name: "expand the pcre src"
command: tar zxvf $src_dir/$pcre_name.tar.gz chdir=$src_dir
- name: "pcre configure"
command: ./configure chdir=$src_dir/$pcre_name
- name: "pcre make"
command: make chdir=$src_dir/$pcre_name
- name: "pcre install"
command: make install chdir=$src_dir/$pcre_name
- name: "wget the httpd src"
get_url: url=$httpd_dl_url dest=$src_dir
- name: "expand httpd src"
command: tar zxvf $httpd_name.tar.gz chdir=$src_dir
- name: "wget the apr"
get_url: url=$apr_dl_url dest=$src_dir
- name: "expand apr src"
command: tar zxvf $apr_name.tar.gz chdir=$src_dir
- name: "copy apr to httpd_dir"
command: cp -rp $src_dir/$apr_name $src_dir/$httpd_name/srclib/apr
- name: "wget ther apr-util"
get_url: url=$apr_util_dl_url dest=$src_dir
- name: "expand ther src"
command: tar zxvf $apr_util_name.tar.gz chdir=$src_dir
- name: "copy apr-util to httpd_dir"
command: cp -rp $src_dir/$apr_util_name $src_dir/$httpd_name/srclib/apr-util
- name: "mkdir httpd"
file: dest=/usr/local/$apache_name state=directory
- name: "make link"
file: src=/usr/local/$apache_name dest=/usr/local/apache2 state=link
- name: "mkdir log"
file: dest=/var/log/httpd state=directory
- name: "configure httpd"
command: chdir=$src_dir/$httpd_name env OPTIM="-02" ./configure --prefix=/usr/local/apache2 --enable-module=so --enable-module=proxy --enable-module=rewrite --enable-module=expires
- name: "httpd make"
command: make chdir=$src_dir/$httpd_name
- name: "httpd install"
command: make install chdir=$src_dir/$httpd_name
- name: "copy apachectl"
command: cp -i /usr/local/apache2/bin/apachectl /etc/init.d/httpd
- name: "chkconfig"
action: service name=httpd state=started enabled=yes
実行方法
ansible-playbook install-httpd-playbook.yml -i hosts -k
configureの箇所で改行したかったんですけど、分からず1行にしてしましました。どこかで見たんだけどな・・・