ansible使用sudo
- 方式一、
- 1、配置资源清单inventory文件
- [root@test1 ~]#
- cat >/etc/ansible/hosts <<EOF
- [k8s]
- 192.168.0.92 ansible_ssh_port=22 ansible_ssh_user=k8s ansible_ssh_pass='' ansible_become_pass=''
- EOF
- 解释:
- ansible_ssh_pass='' 是客户端普通用户的密码
- ansible_become_pass='' 是客户端root用户的密码
- 2、Ansile客户端禁止root直接远程登陆,并创建普通用户ywbz
- [root@test2 ~]# grep -n "PermitRootLogin" /etc/ssh/sshd_config
- PermitRootLogin no
- [root@test2 ~]# systemctl restart sshd
- [root@test2 ~]# useradd k8s
- [root@test2 ~]# echo '123' | passwd --stdin k8s
- Changing password for user k8s.
- passwd: all authentication tokens updated successfully.
- [root@test1 ~]#
- 3、服务端测试执行命令
- [k8s@test1 root]$ ansible test3 -m shell -a 'chmod +x /home/*'
- 4、但是无法创建用户
- 方式二、
- 1、给客户端普通用户配置sudo权限
- 2、配置主机组
- cat >/etc/ansible/hosts<<EOF
- [k8s]
- 192.168.0.92
- [test3]
- 192.168.0.93
- 3、执行
- sudo ansible k8s -m shell -a 'chmod +x /home/*'
ansible使用sudo的更多相关文章
- ansible管理
查看版本: ansible –version 升级pip安装的ansible: sudo pip install -U ansible
- Ansible_自动化运维《Ansible之初识-1》
1.Ansible简介 1.1 Ansible介绍 Ansible 是一个简单的自动化运维管理工具,基于Python开发,集合了众多运维工具(puppet.cfengine.chef.func.fab ...
- 1. Ansible 简介
目录 1. Ansible 是什么? 2. Ansible 特性 3. 控制主机需求 4. 被管理节点需求 1. Ansible 是什么? Ansible 是一个配置管理系统(configuratio ...
- ansible 学习记录
Ansible 的重新学习记录 这里我的Ansible的宿主机是centos 7.2系统,这里我通过yum 安装Ansible 1.配置epel源 sudo yum -y install epel-r ...
- ansible测试环境
ip user sudo_user port usage 192.168.48.81 ansible root 29922 nagios & ansible control 192.168.4 ...
- 1、Ansible初识简要介绍及安装
1.Ansible简介 1.1 Ansible介绍 Ansible 是一个简单的自动化运维管理工具,基于Python开发,集合了众多运维工具(puppet.cfengine.chef.func.fab ...
- ansible常用操作
1.python3中ansible安装模块 在Python3中安装模块需要带上python版本.需要安装模块的版本,默认是安装最新的版本 python3 -m pip install Django== ...
- linux自动化运维工具Ansible saltstack Puppet、Chef、Fabric之间的对比
发现分布式是一个发展的趋势,无论是大型网站的负载均衡架构还是大数据框架部署,以及云存储计算系统搭建都离不开多台服务器的连续部署和环境搭建. 当我们的基础架构是分散式或者基于云的,并且我们经常需要处理在 ...
- 使用ansible远程管理集群
使用ansible远程执行命令 1.ansible简介 ansible的官方定义:"Ansible is Simple IT Automation"--简单的自动化IT工具.这个工 ...
随机推荐
- GitChat·人工智能 | 除了深度学习,机器翻译还需要啥?
本文开始要写作的时候,翻译圈里出了一个“爆炸性”的事件.6月27日下午,一个同传译员在朋友圈里爆料:某AI公司请这位译员去“扮演”机器同传,制造人工智能取代人工同传的“震撼”效果. 这个事件瞬间在译员 ...
- linux 命令格式和帮助
命令的格式: command [options] [arguments] command:命令 options: --单词全称 或 -单字简称 如: ls --all 等于 ls - ...
- Web界面开发必看!Kendo UI for jQuery编辑功能指南第二弹
Kendo UI for jQuery最新试用版下载 Kendo UI目前最新提供Kendo UI for jQuery.Kendo UI for Angular.Kendo UI Support f ...
- jupyter lab 报错
C:\Users\WQBin>jupyter lab [I :: kernels found [I :: No cio_test package found. [I ::45.137 LabAp ...
- 题解 【POJ1934】 Trip
题目意思: 有两个字符串(长度\(<=80\)),按字典序输出它们的最长公共子串的所有情况. 解析 最长公共子序列的长度应该都没问题了吧...有问题请自行百度 但关键是要求出每种情况,还要按字典 ...
- Java基础重点
几个比较重要基础的,以后用到概率比较大的合集. 第一个,是获取时间以字符串形式输出的,用到了Date类.simpleDateFormat类的方法.贴图: 第二个是字符串转时间类型的,与上一个相似,不过 ...
- @RequestMapping的简单理解
@Controller public class ItemController { @Autowired private ItemService itemService; 获取路径参数.../item ...
- java上传超大文件解决方案
用JAVA实现大文件上传及显示进度信息 ---解析HTTP MultiPart协议 (本文提供全部源码下载,请访问 https://github.com/1269085759/up6-jsp-mysq ...
- 日照学习提高班day3测试
A 思路: 一看到'#''.'什么的就想到搜索怪我怪我... 这道题勉强说是搜索别打我qwq 1)因为不重复,所以首先要判断是否%5==0,若不满足,直接输出NO 2)弄个vis数组记录是否被搜过,如 ...
- Thread(简单使用)
/***thread.c***/#include<stdio.h> #include<stdlib.h> #include<pthread.h> void prin ...