Ansible-playbook部署lamp架构

1、准备环境

Redhat8.2 IP 运用
master 192.168.8.129 ansible运维工具
node1 192.168.8.132 apache(httpd)
node2 192.168.8.133 mysql数据库
node3 192.168.8.134 php

2、ansible安装


//安装网络仓库
[root@master ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2595  100  2595    0     0  22964      0 --:--:-- --:--:-- --:--:-- 22964

//安装epel源
[root@master ~]# dnf -y install epel-release

//安装ansible
[root@master ~]# dnf -y install ansible

//查看ansible版本
[root@master ~]#  ansible --version
ansible 2.9.23
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.6/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.6.8 (default, Dec  5 2019, 15:45:45) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]
[root@master ~]# 

  • 构建 一个清单文件,移动到 /opt/project目录下方便管理
[root@master project]# ls  //可以不用移动到/opt/project目录,看个人喜好,如果你没有移动,默认文件应该在/etc/ansible

ansible.cfg  inventory
  • 将要配置httpd、mysql、php的被控主机的IP添加到ansible主机清单
[root@master project]# cat inventory 
[httpd]
192.168.8.132 ansible_user=root ansible_password=1   //用户和密码

[mysql]
192.168.8.133 ansible_user=root ansible_password=1

[php]
192.168.8.134 ansible_user=root ansible_password=1

[root@master project]# 

  • 运用ping模块检查指定节点机器是否连接
[root@master project]# ansible all -m ping
192.168.8.134 | SUCCESS => <
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

彭宇栋

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值