LINUX如何 部署ansible

news/2024/9/22 21:13:59/

        主:192.168.170.49
        被:192.168.170.18


一、启动系统前,加一块光驱,把安装镜像文件放到光驱中

二、配置Yum文件
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# rm -f *
[root@localhost yum.repos.d]# vi cdrom.repo
[BaseOS]
name=BaseOS
baseurl=file:///media/BaseOS
enabled=1
gpgcheck=0

[AppStream]
name=AppStream
baseurl=file:///media/AppStream
enabled=1
gpgcheck=0

[ansible]
name=ansible
baseurl=file:///mnt/ansible
enabled=1
gpgcheck=0

三、挂载光驱,安装ansible
mount /dev/sr1 /media
mount /dev/sr0 /mnt

yum -y install ansible


四、修改配置文件
cd  /etc/ansible/
vim hosts
192.168.1.20

vim ansible.cfg
[defaults]
inventory = /etc/ansible/hosts      
ask_pass = False                          
host_key_checking = False             
remote_user = marry                      
[privilege_escalation]                      
become=True
become_method=sudo
become_user=root
become_ask_pass=False


        主:192.168.170.49
        被:192.168.170.18

五、配置marry免密
1、在远程上新建用户marry
ansible all -m shell -a "useradd marry" -u root -k

2、修改marry的密码
ansible all -m shell -a "echo 123456 |passwd --stdin marry" -u root -k

3、生成公钥对
ssh-keygen

4、把marry的公钥传给被控192.168.1.20
ssh-copy-id marry@192.168.1.20

5、把marry用户提权到root
ansible all -m shell -a ‘echo marry ”ALL=(ALL) NOPASSWD:ALL”>>/etc/sudoers.d/marry’ -u root -k
    
6、测试一下
ansible node2 -m shell -a "ls /root" 


http://www.ppmy.cn/news/1443781.html

相关文章

CMUS狮身人面像(七)-Android 上的 PocketSphinx

本教程介绍了GitHub上提供的演示应用程序。 PocketSphinx Android 演示 为了运行演示应用程序,我们建议使用 Android Studio。您可以从官方下载页面下载Android Studio IDE和sdk 。 从 Android Studio 构建并运行 为了在 IDE 中获取演示,请选择从 VC…

HTML批量文件上传方案——图像预览方式

作者:私语茶馆 1.HTML多文件上传的关键方案 多文件上传包括:文件有效性校验,文件预览、存储和进度展示多个方面,本章节介绍的是文件预览的实现方案。 2.文件上传前预览 2.1.效果 选择文件前: 选择文件后: 2.2.CSS文件代码 StorageCenter.css代码 html {font-family:…

4.29训练赛h题function

1.利用下标和值直接定义b[n]数组 2.如果加入有相同的想到b[n]的二维数组 3.很蠢的问题 ans定义的位置不一样因为每次答案都不样啊&#xff0c;仔细分析一下。。。。 #include <bits/stdc.h> using namespace std; #define int long long const int N1e510; vector&l…

spring-boot控制bean的创建顺序

1、order注解&#xff08;不一定有效&#xff09; org.springframework.core.annotation.Order 2、dependsOn注解&#xff08;有效&#xff09; org.springframework.context.annotation.DependsOn 3、提前将bean注册为BeanDefinition 1、实现BeanDefinitionRegistryPostP…

与Apollo共创生态:我们携手远航

目录 小程一言会议记录 回望7年发展展望未来小程有感 小程一言 4月22日&#xff0c;百度Apollo在北京车展前夕举办了以“破晓•拥抱智变时刻”为主题的智能汽车产品发布会。我在观看后也是很是触动 作为在校大学生的我&#xff0c;从大一开始知道Apollo开始&#xff0c;Apollo…

Kubernetes:云原生时代的核心引擎

文章目录 一、Kubernetes简介&#xff1a;引领云原生潮流二、K8s的核心特性&#xff1a;自动化与智能化三、K8s的实践应用&#xff1a;打造高效云原生应用架构四、K8s的挑战与应对&#xff1a;安全与性能并重五、K8s的未来展望&#xff1a;无限可能与挑战并存《Kubernetes快速进…

Python中format的常见用法

一、填充 1、按默认顺序填充 name "Alice" age 25 print("My name is {} and I am {} years old.".format(name, age))输出&#xff1a;My name is Alice and I am 25 years old. 2、指定位置 name "Bob" age 30 print("My name is…

dremio数据湖sql行列转换及转置

1、行转列 (扁平化) 数据准备 表 aa 1.1 cross join unnest 在Dremio中&#xff0c;UNNEST 函数用于将数组或复杂类型的列&#xff08;如JSON、Map或Array类型&#xff09;中的值“炸裂”&#xff08;分解&#xff09;成多行. with aa as ( select 上海 as city, ARRAY[浦东…