当前位置:网站首页>Ansible及playbook的相关操作
Ansible及playbook的相关操作
2022-06-24 19:48:00 【qq_52178594】
1、给受管主机部署yum仓库,示例如下:
仓库1 : Name: base
Description: baseos
Base url: Index of /centos-vault/8.5.2111/BaseOS/x86_64/os/
需要验证软件包 GPG 签名 GPG key 在 /etc/pki/rpm-gpg/RPM-GPG-KEY-*
启用此软件仓库
仓库 2: Name: app
Description: appstream
Base url: Index of /centos-vault/8.5.2111/AppStream/x86_64/os/
需要验证软件包 GPG 签名 GPG key 在: /etc/pki/rpm-gpg/RPM-GPG-KEY-*
启用此软件仓库
[[email protected] test01]$ vim creat_yum.yml
---
- name: play1
hosts: all
tasks:
- name: create base
yum_repository:
name: base
description: baseos
baseurl: https://mirrors.aliyun.com/centos-vault/8.2.2004/BaseOS/x86_64/os/
gpgcheck: yes
- name: create appstream
yum_repository:
name: app
description: appstream
baseurl: https://mirrors.aliyun.com/centos-vault/8.2.2004/AppStream/x86_64/os/
gpgcheck: yes
- name: install vsftpd
yum:
name: vsftpd
state: latest
注:检查你自己的linux系统版本,并选择相应版本仓库。
部署成功后在受管主机上安装vsftpd软件包
2、给web主机组写一个playbook,该playbook有两个play,第一个play可以保证在web主机组上安装httpd和php,确保web主机组的/var/www/html/目录下面有一个文件为index.php,内容如下:
$ cat /var/www/html/index.php <?php phpinfo();
该playbook里面的第二个play用于测试该web主机组的web服务能否被成功访问index.php内容。
[[email protected] test01]$ vim inventory
[[email protected] test01]$ vim 1.yml
3、在受控节点上添加一个普通用户xiaohong,配置当前控制节点的用户可以免密登录xiaohong用户,并且xiaohong可以sudo。
[[email protected] test01]$ vim 2.yml
---
- name: play1
hosts: node01
tasks:
- name: useradd xiaohong
user:
name: xiaohong
state: present
- name: xiaohong sudoers
lineinfile:
line: "xiaohong ALL=(ALL) NOPASSWD:ALL"
path: /etc/sudoers
- authorized_key:
state: present
user: xiaohong
key: "{
{ lookup('file', '/home/admin/.ssh/id_rsa.pub') }}"
边栏推荐
- 干接点和湿接点
- Scala IO reads binary files
- Use of types, values, namespaces, combinations, etc. in typescript
- 时间统一系统
- Enterprise data leakage prevention solution sharing
- Morris traverse
- VR全景怎么赚钱?结合市场从两个方面客观分析下
- 7-7 digital triangle
- Hibernate学习3 - 自定义SQL
- Tongji and Ali won the CVPR best student thesis, lifeifei won the Huang xutao award, and nearly 6000 people attended the offline conference
猜你喜欢
时间统一系统
美国众议院议员:数字美元将支持美元作为全球储备货币
Enterprise data leakage prevention solution sharing
Tremblement de terre réel ~ projet associé unicloud
STM32CubeIDE SWV功能使用方法
Adding, deleting, querying and modifying MySQL tables
What exactly is Nacos
Ten commandments of self-learning in machine learning
Ultra vires vulnerability & Logic vulnerability (hot) (VIII)
JPA learning 2 - core annotation, annotation addition, deletion, modification and query, list query result return type, one to many, many to one, many to many
随机推荐
7-2 solving the stock buying problem
7-9 treasure hunt route
throttle-debounce. JS: a small anti shake throttling function library
抖音实战~实现App端视频上传与发布
为什么生命科学企业都在陆续上云?
美国众议院议员:数字美元将支持美元作为全球储备货币
Investment analysis and prospect forecast report of global and Chinese octadecyl cyclopentanoate industry from 2022 to 2028
Daily calculation (vowel case conversion)
7-5 maximal submatrix sum problem
Morris遍历
7-3 maximum sub segment and
7-7 digital triangle
时间统一系统
Continuous soul torture from two MySQL indexes of interviewers
VR全景怎么赚钱?结合市场从两个方面客观分析下
js监听页面或元素scroll事件,滚动到底部或顶部
Development status and prospect trend forecast report of humic acid sodium industry in the world and China from 2022 to 2028
【图数据库性能和场景测试利器LDBC SNB】系列一:数据生成器简介 & 应用于GES服务
Andersen global strengthens the Middle East platform with Palestinian member companies
Phprunner 10.7.0 PHP code generator