Ansible学习笔记9

yum_repository模块:

yum_repository模块用于配置yum仓库的。

测试下:

bash 复制代码
[root@localhost ~]# ansible group1 -m yum_repository -a "name=local description=localyum baseurl=file:///mnt/ enabled=yes gpgcheck=no"
192.168.17.106 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": true,
    "repo": "local",
    "state": "present"
}
192.168.17.105 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": true,
    "repo": "local",
    "state": "present"
}

检查:

bash 复制代码
[root@agent1 yum.repos.d]# ll
total 52
-rw-r--r-- 1 root root 1664 Aug 30 13:06 CentOS-Base.repo
-rw-r--r-- 1 root root 1309 Aug 30 13:06 CentOS-CR.repo
-rw-r--r-- 1 root root  649 Aug 30 13:06 CentOS-Debuginfo.repo
-rw-r--r-- 1 root root  314 Aug 30 13:06 CentOS-fasttrack.repo
-rw-r--r-- 1 root root  630 Aug 30 13:06 CentOS-Media.repo
-rw-r--r-- 1 root root 1331 Aug 30 13:06 CentOS-Sources.repo
-rw-r--r-- 1 root root 8515 Aug 30 13:06 CentOS-Vault.repo
-rw-r--r-- 1 root root  616 Aug 30 13:06 CentOS-x86_64-kernel.repo
-rw-r--r-- 1 root root  951 Aug 30 13:06 epel.repo
-rw-r--r-- 1 root root 1050 Aug 30 13:06 epel-testing.repo
-rw-r--r-- 1 root root   73 Aug 30 15:04 local.repo
[root@agent1 yum.repos.d]# cat local.repo
[local]
baseurl = file:///mnt/
enabled = 1
gpgcheck = 0
name = localyum

yum模块(重点):

yum模块用于使用yum命令来实现软件包的安装与卸载。

使用yum安装一个软件(前提:group1的yum配置都已经OK)

检查agent机器,看到vsftpd都已经安装成功。

使用yum模块安装httpd、httpd-devel,state=latest表示安装的最新版本。

可以检查到安装进度:

检查各个agent机器,发现httpd都已经安装。

到agent1机器上检查,看到httpd已经卸载。

bash 复制代码
[root@agent1 yum.repos.d]# rpm -ql httpd
package httpd is not installed

Service模块(重点):

启动vsftpd,并设置为开机自动启动。

停止vsftpd服务,然后关闭开机自动启动。

配置这块内容,就直接用copy模块,将配置文件复制过去。

相关推荐
小安运维日记1 天前
RHCA - DO374 | Day01:使用红帽Ansible自动化平台开发剧本
运维·服务器·云原生·自动化·云计算·ansible
BullSmall1 天前
Ansible三大Web界面方案全解析
运维·ansible
Warren982 天前
复习MySQL
数据库·windows·tcp/ip·mysql·ubuntu·ssh·ansible
早睡冠军候选人5 天前
Ansible学习----Ansible Playbook
运维·服务器·学习·云原生·容器·ansible
yourkin6668 天前
Ansible
ansible
Ribou8 天前
ansible 自动安装软件,实现列表选择软件的方法
ansible
文静小土豆8 天前
Ansible 自动化部署K8S1.34.1
kubernetes·自动化·ansible
K_i13410 天前
Helm 与 Ansible 深度对比解析文档
自动化·ansible
zmjjdank1ng11 天前
什么是Ansible 清单
服务器·自动化·ansible
Yyyy48211 天前
ansible role配apt源
ansible