当前位置:网站首页>RHCE ansible second operation
RHCE ansible second operation
2022-07-19 02:52:00 【 ᝰꫛꫀꪝ】
1、 Deploy to the managed host yum Warehouse , Examples are as follows :
Warehouse 1 :
Name: base
Description: baseos
Base url: https://mirrors.163.com/centos-vault/8.5.2111/BaseOS/x86_64/os/
Need to validate the package GPG Signature
GPG key stay /etc/pki/rpm-gpg/RPM-GPG-KEY-*
Enable this software repository
Warehouse 2:
Name: app
Description: appstream
Base url: https://mirrors.163.com/centos-vault/8.5.2111/AppStream/x86_64/os/
Need to validate the package GPG Signature
GPG key stay : /etc/pki/rpm-gpg/RPM-GPG-KEY-*
Enable this software repository
notes : Check your own linux System version , And select the corresponding version warehouse .
After successful deployment, install on the managed host vsftpd software package
First, make sure that there is ansible.conf and inventory File and configuration is correct
then vim One by .yml Final document
Here we use 1-create-yum.yml For example :
[[email protected] test1]$ vim 1-create-yum.yml
Then edit the following content in the file :

The code is as follows :
---
- 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
2、 to web Host group write one playbook, The playbook There are two play, first play It can be guaranteed in web Install on host group httpd and php, Make sure web Of the host group /var/www/html/ There is a file under the directory named index.php, The contents are as follows :
$ cat /var/www/html/index.php
<?php
phpinfo();
Among them playbook The second one play Used to test the web Of the host group web Whether the service can be successfully accessed index.php Content .
First go to the configuration file to set web Group

Then configure one .yml file
The contents of the document are as follows :

The document code is as follows :
---
- name: play1
hosts: web
tasks:
- name: install httpd
yum:
name:
- httpd
- php
state: latest
- name: create index
copy:
content: "<?php\nphpinfo();\n"
dest: /var/www/html/index.php
- name: delete index.html
file:
path: /var/www/html/index.html
state: absent
- name: add a firewalld rule
firewalld:
service: http
permanent: true
state: enabled
immediate: true
- name: restart httpd
service:
name: httpd
state: restarted
- name: play2
hosts: master
tasks:
- name: ceshi master
uri:
url: http://master
3、 Add a normal user on the controlled node xiaohong, Users who configure the current control node can log in without secret xiaohong user , also xiaohong Sure sudo.
Configure on the control node .yml file
[[email protected] test1]$ vim 3-useradd.yml
The contents of the document are as follows

Because I configured password free login before , So there is no need to generate public-private key pairs
if necessary
Add

The verification results

The document code is as follows :
---
- 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') }}"
边栏推荐
- Shell script variables, script writing and execution (deploy Apache and remote backup MySQL database)
- MySQL备份和恢复
- 微信小程序
- 让我们了解awk~
- 备份kubernetes 备份etcd数据
- Upgrade kubernetes 1.23.2 to 1.24.1
- Leetcode 70:Climbing Stairs
- Let's learn about awk~
- Shell script integer value comparison, logic test, if statement, extract performance monitoring indicators
- shell脚本之循环语句与函数
猜你喜欢
随机推荐
YUM仓库服务与PXE自动部署系统
Leetcode buckle classic topic - 82 Maximum rectangle in column chart
二进制安装kubernetes 1.23.2
微信小程序
Usage instructions for MDK keil/arm printf
Shell脚本变量、脚本编写和执行(部署Apache与远程备份MySQL数据库)
Flyway的SaaS多租户实现方案
RHCE-ansible-第一次作业
认识交换机以及作用
Binary installation kubernetes 1.23.2
微信小程序--Taro框架实际开发中的问题汇总
HCIA_RIP实验
5、AsyncTool框架竟然有缺陷?
[solution] the local Group Policy Editor (gpedit.msc) in Win 11 cannot be opened
SQL之CASE WHEN用法详解
RHCE8学习指南 第7章 服务管理
ENSP static routing experiment
Upgrade kubernetes 1.23.2 to 1.24.1
[unity development tips] unity mixer mixer controls global volume
TCP的三次握手与四次断开








