cat etc/ansible/hosts
[web]
192.168.200.10
[web:vars]
ansible_ssh_user=root
ansible_ssh_pass=‘123456’
ls /etc/ansible/
https.yaml
httpd.conf.j2
index.html
cat /etc/ansbile/httpd.yaml
---
- hosts: web
tasks:
- name: download apr apr-util httpd
get_url: url={{item}} dest=/root/gpk timeout=60
with_items:
- http://mirrors.ustc.edu.cn/apache/apr/apr-1.6.5.tar.gz
- http://mirrors.ustc.edu.cn/apache/apr/apr-util-1.6.1.tar.gz
- http://mirrors.ustc.edu.cn/apache/httpd/httpd-2.4.39.tar.gz
delegate_to: localhost
run_once: True
- name: install pcre pcre-devel
yum: name: {{item}} state=present
with_items:
- pcre
- pcre-devel
- expat-devel #编译apr-util 会出错,安装此包解决
- name: unarchive apr apr-util httpd
unarchive: src=/root/gpk/{{item}} dest=/root/ copy=yes
with_items:
- apr-1.6.5.tar.gz
- apr-util-1.6.1.tar.gz
- httpd-2.4.39.tar.gz
tags: unarchive
- name: complie apr
shell: |
cd /root/apr-1.6.5
./configure --prefix=/usr/local/apr
make && make install
tags: apr
- name: complie apr-util
shell: |
cd apr-util-1.6.1
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make && make install
tags: apr-util
- name: complie httpd
shell: |
cd httpd-2.4.39
./configure --prefix=/usr/local/apache --sysconfdir=/etc/apache/ \
--enable-mpms-shared=all \
--with-z --with-pcre \
--with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr-util \
--with-mpm=event
make && make install
tags: httpd
- name: copy http.conf index.html
tempale: |
src=http.conf.j2 dest=/etc/apache/httpd.conf
src=index.html dest=/usr/local/apache/htdocs/index.html
- name: start httpd
shell: /usr/local/apache/bin/apachectl start