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模块,将配置文件复制过去。

相关推荐
Sweety丶╮7941 小时前
【Ansible】的介绍
云原生·ansible
知白守黑2671 小时前
Ansible角色
运维·服务器·ansible
Sweety丶╮79413 小时前
【Ansible】实施 Ansible Playbook知识点
服务器·云原生·ansible
YC运维2 天前
Ansible题目全解析与答案
java·算法·ansible
--运维实习生--2 天前
自动化运维之ansible
运维·自动化·ansible
神秘人X7073 天前
Ansible 角色使用指南
ansible·角色
维尔切4 天前
自动化运维-ansible中对于大项目的管理
运维·自动化·ansible
Gss7774 天前
ansible变量+管理机密
linux·运维·ansible
误入运维泥潭4 天前
Ansible自动化运维:从入门到精通
linux·ansible·module
半梦半醒*4 天前
ansible阶段练习题
linux·运维·自动化·ansible·负载均衡·运维开发