1. 方式一、
  2.  
  3. 1、配置资源清单inventory文件
  4.  
  5. [root@test1 ~]#
  6. cat >/etc/ansible/hosts <<EOF
  7. [k8s]
  8. 192.168.0.92 ansible_ssh_port=22 ansible_ssh_user=k8s ansible_ssh_pass='' ansible_become_pass=''
  9. EOF
  10.  
  11. 解释:
  12.  
  13. ansible_ssh_pass='' 是客户端普通用户的密码
  14. ansible_become_pass='' 是客户端root用户的密码
  15.  
  16. 2Ansile客户端禁止root直接远程登陆,并创建普通用户ywbz
  17.  
  18. [root@test2 ~]# grep -n "PermitRootLogin" /etc/ssh/sshd_config
  19. PermitRootLogin no
  20. [root@test2 ~]# systemctl restart sshd
  21. [root@test2 ~]# useradd k8s
  22. [root@test2 ~]# echo '123' | passwd --stdin k8s
  23. Changing password for user k8s.
  24. passwd: all authentication tokens updated successfully.
  25. [root@test1 ~]#
  26.  
  27. 3、服务端测试执行命令
  28.  
  29. [k8s@test1 root]$ ansible test3 -m shell -a 'chmod +x /home/*'
  30.  
  31. 4、但是无法创建用户
  32.  
  33. 方式二、
  34.  
  35. 1、给客户端普通用户配置sudo权限
  36.  
  37. 2、配置主机组
  38.  
  39. cat >/etc/ansible/hosts<<EOF
  40. [k8s]
  41. 192.168.0.92
  42.  
  43. [test3]
  44. 192.168.0.93
  45.  
  46. 3、执行
  47.  
  48. sudo ansible k8s -m shell -a 'chmod +x /home/*'

ansible使用sudo的更多相关文章

  1. ansible管理

    查看版本: ansible –version 升级pip安装的ansible: sudo pip install -U ansible

  2. Ansible_自动化运维《Ansible之初识-1》

    1.Ansible简介 1.1 Ansible介绍 Ansible 是一个简单的自动化运维管理工具,基于Python开发,集合了众多运维工具(puppet.cfengine.chef.func.fab ...

  3. 1. Ansible 简介

    目录 1. Ansible 是什么? 2. Ansible 特性 3. 控制主机需求 4. 被管理节点需求 1. Ansible 是什么? Ansible 是一个配置管理系统(configuratio ...

  4. ansible 学习记录

    Ansible 的重新学习记录 这里我的Ansible的宿主机是centos 7.2系统,这里我通过yum 安装Ansible 1.配置epel源 sudo yum -y install epel-r ...

  5. ansible测试环境

    ip user sudo_user port usage 192.168.48.81 ansible root 29922 nagios & ansible control 192.168.4 ...

  6. 1、Ansible初识简要介绍及安装

    1.Ansible简介 1.1 Ansible介绍 Ansible 是一个简单的自动化运维管理工具,基于Python开发,集合了众多运维工具(puppet.cfengine.chef.func.fab ...

  7. ansible常用操作

    1.python3中ansible安装模块 在Python3中安装模块需要带上python版本.需要安装模块的版本,默认是安装最新的版本 python3 -m pip install Django== ...

  8. linux自动化运维工具Ansible saltstack Puppet、Chef、Fabric之间的对比

    发现分布式是一个发展的趋势,无论是大型网站的负载均衡架构还是大数据框架部署,以及云存储计算系统搭建都离不开多台服务器的连续部署和环境搭建. 当我们的基础架构是分散式或者基于云的,并且我们经常需要处理在 ...

  9. 使用ansible远程管理集群

    使用ansible远程执行命令 1.ansible简介 ansible的官方定义:"Ansible is Simple IT Automation"--简单的自动化IT工具.这个工 ...

随机推荐

  1. GitChat·人工智能 | 除了深度学习,机器翻译还需要啥?

    本文开始要写作的时候,翻译圈里出了一个“爆炸性”的事件.6月27日下午,一个同传译员在朋友圈里爆料:某AI公司请这位译员去“扮演”机器同传,制造人工智能取代人工同传的“震撼”效果. 这个事件瞬间在译员 ...

  2. linux 命令格式和帮助

    命令的格式: command [options] [arguments] command:命令 options:  --单词全称   或   -单字简称 如: ls --all 等于     ls - ...

  3. Web界面开发必看!Kendo UI for jQuery编辑功能指南第二弹

    Kendo UI for jQuery最新试用版下载 Kendo UI目前最新提供Kendo UI for jQuery.Kendo UI for Angular.Kendo UI Support f ...

  4. jupyter lab 报错

    C:\Users\WQBin>jupyter lab [I :: kernels found [I :: No cio_test package found. [I ::45.137 LabAp ...

  5. 题解 【POJ1934】 Trip

    题目意思: 有两个字符串(长度\(<=80\)),按字典序输出它们的最长公共子串的所有情况. 解析 最长公共子序列的长度应该都没问题了吧...有问题请自行百度 但关键是要求出每种情况,还要按字典 ...

  6. Java基础重点

    几个比较重要基础的,以后用到概率比较大的合集. 第一个,是获取时间以字符串形式输出的,用到了Date类.simpleDateFormat类的方法.贴图: 第二个是字符串转时间类型的,与上一个相似,不过 ...

  7. @RequestMapping的简单理解

    @Controller public class ItemController { @Autowired private ItemService itemService; 获取路径参数.../item ...

  8. java上传超大文件解决方案

    用JAVA实现大文件上传及显示进度信息 ---解析HTTP MultiPart协议 (本文提供全部源码下载,请访问 https://github.com/1269085759/up6-jsp-mysq ...

  9. 日照学习提高班day3测试

    A 思路: 一看到'#''.'什么的就想到搜索怪我怪我... 这道题勉强说是搜索别打我qwq 1)因为不重复,所以首先要判断是否%5==0,若不满足,直接输出NO 2)弄个vis数组记录是否被搜过,如 ...

  10. Thread(简单使用)

    /***thread.c***/#include<stdio.h> #include<stdlib.h> #include<pthread.h> void prin ...