当前位置:网站首页>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') }}"
边栏推荐
- What you must know about time series database!
- One way 和two way ANOVA分析的区别是啥,以及如何使用SPSS或者prism进行统计分析
- Why do more and more physical stores use VR panorama? What are the advantages?
- 7-2 construction of binary tree by post order + middle order sequence
- Analysis report on production and marketing demand and investment forecast of China's boron nitride industry from 2022 to 2028
- VR全景制作的优势是什么?为什么能得到青睐?
- 7-2 solving the stock buying problem
- Hibernate学习3 - 自定义SQL
- Andersen Global借助巴勒斯坦成员公司加强中东平台
- Opengauss kernel: simple query execution
猜你喜欢

Is there really something wrong with my behavior?

Stm32f030f4 reading infrared remote control data

我的为人处事真的有问题吗?

抖音實戰~項目關聯UniCloud

Opengauss kernel: simple query execution

怎么把wps表格里某一列有重复项的整行删掉

js监听页面或元素scroll事件,滚动到底部或顶部

Hibernate learning 3 - custom SQL

JPA learning 1 - overview, JPA, JPA core annotations, JPA core objects

Yyds dry goods counting uses xshell to implement agent function
随机推荐
普通人的生活准则
Using ADC to control brushless motor source program STM32 library function
Adding, deleting, querying and modifying MySQL tables
Leetcode topic [array] -39- combined sum
7-7 solving mode problems
The living standards of ordinary people
SAP PA certificate for no birds, which can be tested by new peers
Understanding openstack network
磁带svg动画js特效
svg线条动画背景js特效
Tutorial details | how to edit and set the navigation function in the coolman system?
Tongji and Ali won the CVPR best student thesis, lifeifei won the Huang xutao award, and nearly 6000 people attended the offline conference
7-9 treasure hunt route
In the past 5 years, from "Diandian" to the current test development, my success is worth learning from.
7-8 ladder cloud vertical
Investment analysis and prospect forecast report of global and Chinese propargyl chloride industry from 2022 to 2028
Start QT program
Daily calculation (vowel case conversion)
Hello C (two) -- use of bit operation
Tremblement de terre réel ~ projet associé unicloud