ansible playbook使用变量源码安装apache
2021/7/23 9:35:56
本文主要是介绍ansible playbook使用变量源码安装apache,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
先在ansible主机上下载安装apache需要的文件
[root@ansible playbook]# wget https://mirrors.tuna.tsinghua.edu.cn/apache/apr/apr-1.7.0.tar.gz [root@ansible playbook]# wget https://mirrors.tuna.tsinghua.edu.cn/apache/apr/apr-util-1.6.1.tar.gz [root@ansible playbook]# wget https://mirrors.tuna.tsinghua.edu.cn/apache/httpd/httpd-2.4.48.tar.gz
然后解压到本机上
[root@ansible playbook]# ls apr-1.7.0.tar.gz apr-util-1.6.1.tar.gz httpd-2.4.48.tar.gz [root@ansible playbook]# mkdir files [root@ansible playbook]# tar -xf apr-1.7.0.tar.gz -C files/ [root@ansible playbook]# tar -xf apr-util-1.6.1.tar.gz -C files/ [root@ansible playbook]# tar -xf httpd-2.4.48.tar.gz -C files/ [root@ansible playbook]# ls files/ apr-1.7.0 apr-util-1.6.1 httpd-2.4.48 [root@ansible playbook]#
然后写playbook文件
[root@ansible project]# cat playbook/apache.yml --- - name: install apache hosts: all vars: apr_name: apr-1.7.0 apr_util_name: apr-util-1.6.1 httpd_name: httpd-2.4.48 tasks: - name: copy apr copy: src: files/{{apr_name}} dest: /root/ - name: copy apr-util copy: src: files/{{apr_util_name}} dest: /root/ - name: copy httpd copy: src: files/{{httpd_name}} dest: /root/ - name: stop firewalld service: name: firewalld state: stopped enabled: no - name: stop selinux lineinfile: path: /etc/selinux/config regexp: "^SELINUX=" line: "SELINUX=disabled" state: present - name: install utils yum: name: "{{item}}" state: present with_items: - openssl-devel - pcre-devel - pcre - perl - perl-devel - expat-devel - libtool - gcc - make - gcc-c++ - name: edit config lineinfile: path: /root/{{apr_name}}/configure regexp: '^ $RM "$cfgfile"' line: '# $RM "$cfgfile"' - name: install apr shell: | cd /root/apr-1.7.0 ./configure --prefix=/usr/local/apr make && make install - name: install apr-util shell: | cd /root/apr-util-1.6.1 ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr make && make install - name: install httpd shell: | cd /root/httpd-2.4.48 ./configure --prefix=/usr/local/httpd --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util make && make install - name: edit httpd config lineinfile: path: /usr/local/httpd/conf/httpd.conf regexp: "^#ServerName www.example.com:80" line: "ServerName www.example.com:80" - name: start httpd shell: '/usr/local/httpd/bin/apachectl start' [root@ansible project]#
查看测试结果
这篇关于ansible playbook使用变量源码安装apache的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-12-22怎么通过控制台去看我的页面渲染的内容在哪个文件中呢-icode9专业技术文章分享
- 2024-12-22el-tabs 组件只被引用了一次,但有时会渲染两次是什么原因?-icode9专业技术文章分享
- 2024-12-22wordpress有哪些好的安全插件?-icode9专业技术文章分享
- 2024-12-22wordpress如何查看系统有哪些cron任务?-icode9专业技术文章分享
- 2024-12-21Svg Sprite Icon教程:轻松入门与应用指南
- 2024-12-20Excel数据导出实战:新手必学的简单教程
- 2024-12-20RBAC的权限实战:新手入门教程
- 2024-12-20Svg Sprite Icon实战:从入门到上手的全面指南
- 2024-12-20LCD1602显示模块详解
- 2024-12-20利用Gemini构建处理各种PDF文档的Document AI管道