• Ansible主机清单书写演示和ansible.cfg配置文件详解


    目录

    主机清单(常见为INI格式)

    一.定义主机列表

    1.每行写一个

    2.主机组

    (1)定义简单主机组

    (2)指定多台主机时可以通过书写范围来表示

    (3)定义嵌套主机组

    二.匹配主机和组

    1.匹配所有主机

    (1)all

    (2)特殊使用*号,单独使用无效

    2.匹配指定主机或组

    (1)匹配一个或多个组

    (2)匹配一个或多个主机

    3.匹配未分配组的主机

    4.通配符匹配

    (1)以什么开头或结尾的主机,或者是通过组名匹配出来的主机

    (2)匹配非匹配范围内的主机,或者非匹配范围内的组匹配出来的主机

    (3)匹配包含某关键字的主机或包含某关键的组内的主机

    (4)匹配同时属于两个组的主机

    5.正则表达式匹配

    6.通过limit来匹配主机

    ansible配置文件

    一.优先级

    二.配置文件详解

    1.defaults部分

    2.privilege_escalation

    3.paramiko_connection

    4.ssh_connection

    5.persistent_connection

    6.accelerate(加速模块ansible1.5版本后很少用)

    7.selinux

    8.简单测试是否能够进行节点通信

    主机清单和配置文件练习

    1.安装并配置ansible,在控制节点上安装并配置ansible

    2.创建并运行 Ansibie ad-hoc 命令


     

    主机清单(常见为INI格式)

    一.定义主机列表

    1.每行写一个

    可以是域名、主机名、IP地址,此时它们没有被分到任何一个组内,属于ungroup

    1. [student@workstation ~]$ cat myhosts
    2. servera.xxx.com
    3. serverb
    4. 172.25.xxx.xx
    5. [student@workstation ~]$ ansible-inventory -i myhosts --graph #-i指定主机文件,--graph创建库存图
    6. @all:
    7. |--@ungrouped:
    8. | |--172.25.xxx.xx
    9. | |--servera.xxx.com
    10. | |--serverb

    2.主机组

    (1)定义简单主机组

    1. [student@workstation ~]$ cat myhosts1
    2. [webservers]
    3. servera
    4. serverb
    5. [dbservers]
    6. serverc
    7. serverd.lab.example.com
    8. [student@workstation ~]$ ansible-inventory -i myhosts1 --graph  
    9. #默认的主机文件是/etc/ansible/hosts,使用其他文件时需要指定
    10. @all:
    11. |--@dbservers:
    12. | |--serverc
    13. | |--serverd.lab.example.com
    14. |--@ungrouped:
    15. |--@webservers:
    16. | |--servera
    17. | |--serverb

    (2)指定多台主机时可以通过书写范围来表示

    1. [student@workstation ~]$ cat myhosts2
    2. [mywebservers]
    3. server[a:d]     #以“[x:y]”来表示从x到y的范围
    4. [student@workstation ~]$ ansible mywebservers -i myhosts2 --list-hosts  
    5. #通过指定具体的主机文件中的组名来查看组下主机
    6. hosts (4):
    7.   servera
    8.   serverb
    9.   serverc
    10.   serverd

    (3)定义嵌套主机组

    1. [student@workstation ~]$ cat myhosts1
    2. [webservers]
    3. servera
    4. serverb
    5. [dbservers]
    6. serverc
    7. serverd.lab.example.com
    8. [conment:children]   #以“:children表示包含若干组”
    9. webservers
    10. [student@workstation ~]$ ansible conment -i myhosts1 --list-hosts
    11. hosts (2):
    12.   servera
    13.   serverb

    二.匹配主机和组

    1.匹配所有主机

    (1)all

    1. [student@workstation ~]$ ansible all -i myhosts1 --list-hosts
    2. hosts (4):
    3.   serverc
    4.   serverd.lab.example.com
    5.   servera
    6.   serverb

    (2)特殊使用*号,单独使用无效

    1. [student@workstation ~]$ ansible * -i myhosts1 --list-hosts
    2. [WARNING]: Could not match supplied host pattern, ignoring: myhosts1
    3. [WARNING]: No hosts matched, nothing to do
    4. hosts (0):
    5. [student@workstation ~]$ ansible \* -i myhosts1 --list-hosts #转义
    6. hosts (4):
    7.   serverc
    8.   serverd.lab.example.com
    9.   servera
    10.   serverb
    11.    
    12. [student@workstation ~]$ ansible '*' -i myhosts1 --list-hosts   #单引号
    13. hosts (4):
    14.   serverc
    15.   serverd.lab.example.com
    16.   servera
    17.   serverb
    18. [student@workstation ~]$ ansible "*" -i myhosts1 --list-hosts   #双引号
    19. hosts (4):
    20.   serverc
    21.   serverd.lab.example.com
    22.   servera
    23.   serverb
    24. [student@workstation ~]$ ansible '''*''' -i myhosts1 --list-hosts   #三引号
    25. hosts (4):
    26.   serverc
    27.   serverd.lab.example.com
    28.   servera
    29.   serverb

    2.匹配指定主机或组

    (1)匹配一个或多个组

    1. [student@workstation ~]$ ansible webservers -i myhosts1 --list-hosts
    2. hosts (2):
    3.   servera
    4.   serverb
    5. [student@workstation ~]$ ansible webservers,dbservers -i myhosts1 --list-hosts  
    6. #多个组以“,”分隔,这行也可以理解为属于“webservers”或“dbservers”组的主机
    7. hosts (4):
    8.   servera
    9.   serverb
    10.   serverc
    11.   serverd.lab.example.com

    (2)匹配一个或多个主机

    1. [student@workstation ~]$ ansible servera -i myhosts1 --list-hosts
    2. hosts (1):
    3.   servera
    4. [student@workstation ~]$ ansible servera,serverc -i myhosts1 --list-hosts  
    5. #多个主机以“,”分隔
    6. hosts (2):
    7.   servera
    8.   serverc

    3.匹配未分配组的主机

    1. [student@workstation ~]$ ansible ungrouped -i myhosts1 --list-hosts
    2. hosts (1):
    3.   haha

    4.通配符匹配

    (1)以什么开头或结尾的主机,或者是通过组名匹配出来的主机

    1. [student@workstation ~]$ ansible 'server*' -i myhosts1 --list-hosts
    2. hosts (4):
    3.   servera
    4.   serverb
    5.   serverc
    6.   serverd.lab.example.com
    7. [student@workstation ~]$ ansible '*.com' -i myhosts1 --list-hosts
    8. hosts (1):
    9.   serverd.lab.example.com
    10. [student@workstation ~]$ ansible 'web*' -i myhosts1 --list-hosts
    11. hosts (2):
    12.   servera
    13.   serverb
    14.    
    15. [student@workstation ~]$ ansible 'db*' -i myhosts1 --list-hosts
    16. hosts (2):
    17.   serverc
    18.   serverd.lab.example.com

    (2)匹配非匹配范围内的主机,或者非匹配范围内的组匹配出来的主机

    1. [student@workstation ~]$ ansible '!*.com' -i myhosts1 --list-hosts  
    2. #使用"!"
    3. hosts (4):
    4.   haha
    5.   serverc
    6.   servera
    7.   serverb
    8. [student@workstation ~]$ ansible '!web*' -i myhosts1 --list-hosts  
    9. #匹配出来的是"dbservers"组内的主机
    10. hosts (3):
    11.   haha
    12.   serverc
    13.   serverd.lab.example.com
    14.    
    15. [student@workstation ~]$ ansible 'server*,!*.com' -i myhosts1 --list-hosts
    16. #匹配以"server"开头但不以".com"结尾的主机
    17. hosts (3):
    18.   servera
    19.   serverb
    20.   serverc
    21.    
    22. [student@workstation ~]$ ansible 'w*,!*s' -i myhosts1 --list-hosts  
    23. #匹配以"w"开头但不以"s"结尾的组内的主机
    24. hosts (2):
    25.   server1
    26.   serverh
    27. [student@workstation ~]$ cat myhosts1
    28. haha
    29. [webservers]
    30. servera
    31. serverb
    32. [dbservers]
    33. serverc
    34. serverd.lab.example.com
    35. [webservers1]
    36. server1
    37. serverh
    38. [conment:children]
    39. webservers

    (3)匹配包含某关键字的主机或包含某关键的组内的主机

    1. [student@workstation ~]$ ansible '*server*' -i myhosts1 --list-hosts
    2. hosts (6):
    3.   servera
    4.   serverb
    5.   serverc
    6.   serverd.lab.example.com
    7.   server1
    8.   serverh
    9. [student@workstation ~]$ ansible '*web*' -i myhosts1 --list-hosts
    10. hosts (4):
    11.   servera
    12.   serverb
    13.   server1
    14.   serverh

    (4)匹配同时属于两个组的主机

    1. [student@workstation ~]$ ansible-inventory -i myhosts1 --graph
    2. @all:
    3. |--@conment:
    4. | |--@webservers:
    5. | | |--servera
    6. | | |--serverb
    7. |--@dbservers:
    8. | |--serverc
    9. | |--serverd.lab.example.com
    10. |--@ungrouped:
    11. | |--haha
    12. |--@webservers1:
    13. | |--server1
    14. | |--servera
    15. | |--serverh
    16.  
    17. [student@workstation ~]$ ansible 'webservers,&webservers1' -i myhosts1 --list-hosts  
    18. #逻辑与“&”,逻辑或见“2(1)示例,逻辑非“!”见4(2)示例
    19. hosts (1):
    20.   servera

    5.正则表达式匹配

    1. [student@workstation ~]$ ansible-inventory -i myhosts1 --graph
    2. @all:
    3. |--@conment:
    4. | |--@webservers:
    5. | | |--servera
    6. | | |--serverb
    7. |--@dbservers:
    8. | |--serverc
    9. | |--serverd.lab.example.com
    10. |--@ungrouped:
    11. | |--haha
    12. |--@webservers1:
    13. | |--server1
    14. | |--servera
    15. | |--serverh
    16. [student@workstation ~]$ ansible '~^(s|c)' -i myhosts1 --list-hosts
    17. #“~”表示标记这是一个正则表达式,以“s”开头或以“c”开头,以“s”开头的输出后,没有以“c”开头的主机,但有以“c”开头的组,会输出其下的主机
    18. hosts (6):
    19.   servera
    20.   serverb
    21.   serverc
    22.   serverd.lab.example.com
    23.   server1
    24.   serverh
    25.    
    26. [student@workstation ~]$ ansible '~^(o|c)' -i myhosts1 --list-hosts
    27. hosts (2):
    28.   servera
    29.   serverb

    6.通过limit来匹配主机

    1. [student@workstation ~]$ ansible server* -i myhosts1 --list-hosts --limit servera #可以在后面直接指定
    2. hosts (1):
    3.   servera
    4. [student@workstation ~]$ ansible server* -i myhosts1 --list-hosts --limit @list #可以指定定义好主机的文件
    5. hosts (1):
    6.   servera
    7. [student@workstation ~]$ cat list
    8. servera

    ansible配置文件

    一.优先级

    一般情况下的主要就是"ANSIBLE_CONFIG=指定.cfg文件的绝对路径" > ./ansible.cfg" > "~/.ansible.cfg" > "/etc/ansible/ansible.cfg"

    1. [student@workstation ~]$ ansible --version
    2. ansible 2.8.0
    3. config file = /etc/ansible/ansible.cfg   #当前使用的是"/etc/ansible/ansible.cfg"
    4. configured module search path = ['/home/student/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
    5. ansible python module location = /usr/lib/python3.6/site-packages/ansible
    6. executable location = /usr/bin/ansible
    7. python version = 3.6.8 (default, Apr 3 2019, 17:26:03) [GCC 8.2.1 20180905 (Red Hat 8.2.1-3)]

    ANSIBLE_CONFIG用法示例

    1. [student@workstation ~]$ cat ansible.cfg
    2. [defaults]
    3. inventory=/home/student/myhosts1
    4. [student@workstation ~]$ ll
    5. total 12
    6. -rw-rw-r--. 1 student student 45 Oct 12 10:30 ansible.cfg
    7. -rw-rw-r--. 1 student student   8 Oct 12 09:34 list
    8. -rw-rw-r--. 1 student student 149 Oct 12 08:58 myhosts1
    9. [student@workstation ~]$ ANSIBLE_CONFIG=/home/student/ansible ansible webservers --list-hosts
    10. hosts (2):
    11.   servera
    12.   serverb
    13. [student@workstation ~]$ ansible --version
    14. ansible 2.8.0
    15. config file = /home/student/ansible.cfg   #此时默认配置文件就变了
    16. configured module search path = ['/home/student/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
    17. ansible python module location = /usr/lib/python3.6/site-packages/ansible
    18. executable location = /usr/bin/ansible
    19. python version = 3.6.8 (default, Apr 3 2019, 17:26:03) [GCC 8.2.1 20180905 (Red Hat 8.2.1-3)]
    20. [student@workstation ~]$ export ANSIBLE_CONFIG=/home/student/ansible.cfg  
    21. #也可以export声明这个文件的路径,可以通过unset进行取消配置
    22. [student@workstation ~]$ ansible --version
    23. ansible 2.8.0
    24. config file = /home/student/ansible.cfg
    25. configured module search path = ['/home/student/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
    26. ansible python module location = /usr/lib/python3.6/site-packages/ansible
    27. executable location = /usr/bin/ansible
    28. python version = 3.6.8 (default, Apr 3 2019, 17:26:03) [GCC 8.2.1 20180905 (Red Hat 8.2.1-3)]

    二.配置文件详解

    1.defaults部分

    1. [defaults]
    2. inventory=   #指定清单文件路径
    3. remote_user=   #用来在受管节点上登录的用户名,不指定则为当前用户
    4. become=True #连接后是否在受管节点上切换用户,一般是切换到root
    5. become_method=sudo #以sudo方式切换,也可以选择su
    6. become_user=root   #在受管节点上要切换的用户,默认root
    7. sudo_user=root #默认执行命令的用户
    8. ask_sudo_pass=True   #是否需要sudo密码
    9. become_ask_pass=False #是否为切换方式提示输入密码,默认false
    10. host_key_checking=False #首次连接时是否检查ssh主机的密钥
    11. ask_pass=True #是否提示输入ssh连接密码,使用公钥验证应为false
    12. library=/usr/share/my_modules/ #指定存放ansible模块的目录
    13. timeout=10 #远程连接超时时间,以秒为单位
    14. log_path=/var/log/ansible.log   #指定ansible的日志存储文件位置
    15. private_key_file=/path/to/file   #私钥密钥路径
    16. roles_path=/etc/ansible/roles # role存放目录
    17. forks= 5   #设置默认多少个进程同时运行,进程并发数,默认5
    18. remote_port   = 22   #连接受管节点的管理端口,ssh22端口
    19. poll_interval=15   #轮询间隔时间,默认15
    20. module_name =   #默认执行的模块
    21. #action_plugins     = /usr/share/ansible/plugins/action
    22. #become_plugins     = /usr/share/ansible/plugins/become
    23. #cache_plugins     = /usr/share/ansible/plugins/cache
    24. #callback_plugins   = /usr/share/ansible/plugins/callback
    25. #connection_plugins = /usr/share/ansible/plugins/connection
    26. #lookup_plugins     = /usr/share/ansible/plugins/lookup
    27. #inventory_plugins = /usr/share/ansible/plugins/inventory
    28. #vars_plugins       = /usr/share/ansible/plugins/vars
    29. #filter_plugins     = /usr/share/ansible/plugins/filter
    30. #test_plugins       = /usr/share/ansible/plugins/test
    31. #terminal_plugins   = /usr/share/ansible/plugins/terminal
    32. #strategy_plugins   = /usr/share/ansible/plugins/strategy
    33. #此上等等为各插件存放位置

    2.privilege_escalation

    1. [privilege_escalation]
    2. become=True #是否切换用户
    3. become_method=sudo #以什么方式切换
    4. become_user=root #切换到哪个用户
    5. become_ask_pass=False   #是否需要sudo密码

    3.paramiko_connection

    1. [paramiko_connection]
    2. record_host_keys=False #是否记录新主机的密钥,类似于保存用户在此节点的密码
    3. pty=False   #是否禁用sudo功能
    4. look_for_keys=False   #是否在~/.ssh中寻找密钥文件
    5. host_key_auto_add=True #是否自动添加主机密钥

    4.ssh_connection

    1. [ssh_connection]
    2. scp_if_ssh = smart  
    3. #设置传输机制,smart先尝试sftp后尝试scp,True只使用scp,False只使用sftp
    4. transfer_method = smart
    5. #同scp_if_ssh,两者同时设置时后者覆盖前者,但在scp_if_ssh基础上新增了piped模式表示通过ssh的'dd'来传输,并且在smart模式下,尝试传输顺序为sftp-scp-piped
    6. sftp_batch_mode = False   # 是否批处理模式来传输文件
    7. usetty = True   #是否启动管道传输
    8. retries = 3 #重试与主机重连次数

    5.persistent_connection

    1. [persistent_connection]
    2. connect_timeout = 30  
    3. #持久链接超时时间,在这个值之前收到连接请求,连接才不会被关闭,默认30
    4. command_timeout = 30  
    5. #命令超时时间,意思是设置在连接超时前分配多少时间等待命令请求或RPC调用请求,需要小于等于持久连接超时时间

    6.accelerate(加速模块ansible1.5版本后很少用)

    7.selinux

    1. [selinux]
    2. special_context_filesystems=nfs,vboxsf,fuse,ramfs,9p
    3. #处理selinux时需要的特殊文件系统
    4. libvirt_lxc_noseclabel = yes
    5. #是否允许libvirt_lxc相关链接有或没有selinux的情况下运行

    8.简单测试是否能够进行节点通信

    1. [student@workstation ~]$ cat ansible.cfg
    2. [defaults]
    3. inventory=/home/student/myhosts1
    4. remote_user=root
    5. become_user=True
    6. become_method=sudo
    7. host_key_checking=False
    8. ask_pass=False
    9. [privilege_escalation]
    10. become=True
    11. become_method=sudo
    12. become_user=root
    13. become_ask_pass=False
    14. [student@workstation ~]$ cat myhosts1
    15. [webservers]
    16. servera
    17. serverb
    18. [dbservers]
    19. serverc
    20. serverd.lab.example.com
    21. [conment:children]
    22. webservers
    23. [student@workstation ~]$ ansible all -m ping
    24. serverd.lab.example.com | SUCCESS => {
    25.   "ansible_facts": {
    26.       "discovered_interpreter_python": "/usr/libexec/platform-python"
    27.   },
    28.   "changed": false,
    29.   "ping": "pong"
    30. }
    31. serverc | SUCCESS => {
    32.   "ansible_facts": {
    33.       "discovered_interpreter_python": "/usr/libexec/platform-python"
    34.   },
    35.   "changed": false,
    36.   "ping": "pong"
    37. }
    38. serverb | SUCCESS => {
    39.   "ansible_facts": {
    40.       "discovered_interpreter_python": "/usr/libexec/platform-python"
    41.   },
    42.   "changed": false,
    43.   "ping": "pong"
    44. }
    45. servera | SUCCESS => {
    46.   "ansible_facts": {
    47.       "discovered_interpreter_python": "/usr/libexec/platform-python"
    48.   },
    49.   "changed": false,
    50.   "ping": "pong"
    51. }

    主机清单和配置文件练习

    1.安装并配置ansible,在控制节点上安装并配置ansible

    (1)创建静态inventory文件/home/devops/ansible/inventory,要求如下:
    servera属于dev组
    serverb属于test和balancers组
    serverc和serverd属于prod组
    prod组属于Webserver组

    (2)创建ansible配置文件/home/devops/ansible/ansible.cfg,要求如下:
    使用/home/devops/ansible/inventory清单文件
    角色role目录路径为/home/devops/ansible/roles 

    没有/home/devops/ansible目录需要先创建该目录

    1. [kiosk@foundation0 ~]$ rht-vmctl start all
    2. Error: bastion not started (is already running)
    3. Error: workstation not started (is already running)
    4. Error: servera not started (is already running)
    5. Error: serverb not started (is already running)
    6. Error: serverc not started (is already running)
    7. Error: serverd not started (is already running)
    8. [kiosk@foundation0 ~]$ ssh devops@workstation
    9. Activate the web console with: systemctl enable --now cockpit.socket
    10. Last login: Mon Jun 19 18:46:41 2023 from 172.25.250.250
    11. [devops@workstation ~]$ mkdir /home/devops/ansible

    到该目录下创建inventory文件,ansible.cfg文件,roles文件,参照/etc/ansible/ansible.cfg配置内容

    1. [devops@workstation ~]$ cd /home/devops/ansible/
    2. [devops@workstation ansible]$ ll
    3. total 12
    4. -rw-r--r--. 1 root root 114 Jun 19 19:19 ansible.cfg
    5. -rw-r--r--. 1 root root 148 Jun 19 19:19 inventory
    6. -rw-r--r--. 1 root root 1 Jun 19 19:03 roles
    7. [devops@workstation ~]$ cat /etc/ansible/ansible.cfg
    8. [devops@workstation ansible]$ cat ansible.cfg
    9. [defaults]
    10. inventory=/home/devops/ansible/inventory
    11. roles_path=/home/devops/ansible/roles
    12. host_key_checking=False
    13. [devops@workstation ansible]$ cat inventory
    14. [dev]
    15. servera
    16. [test]
    17. serverb
    18. [balancers]
    19. serverb
    20. [prod]
    21. server[c:d]
    22. [Webserver:children]
    23. prod
    24. [all:vars]
    25. ansible_user=root
    26. ansible_password=redhat

    测试连通性

    1. [devops@workstation ansible]$ ansible all -m ping
    2. servera | SUCCESS => {
    3. "ansible_facts": {
    4. "discovered_interpreter_python": "/usr/libexec/platform-python"
    5. },
    6. "changed": false,
    7. "ping": "pong"
    8. }
    9. serverd | SUCCESS => {
    10. "ansible_facts": {
    11. "discovered_interpreter_python": "/usr/libexec/platform-python"
    12. },
    13. "changed": false,
    14. "ping": "pong"
    15. }
    16. serverc | SUCCESS => {
    17. "ansible_facts": {
    18. "discovered_interpreter_python": "/usr/libexec/platform-python"
    19. },
    20. "changed": false,
    21. "ping": "pong"
    22. }
    23. serverb | SUCCESS => {
    24. "ansible_facts": {
    25. "discovered_interpreter_python": "/usr/libexec/platform-python"
    26. },
    27. "changed": false,
    28. "ping": "pong"
    29. }

    2.创建并运行 Ansibie ad-hoc 命令

    创建一个 shell 脚本名为 adhoc.sh 用以运行 ad-hoc 命令 . 为每个受控节点配罝 yum仓库. 要求如下:
    仓库1:
    Name:RH294_Base
    Description:RH294 base software
    Baseurl:http://content.example.com/rhel8.0/x86_64/dvd/BaseOS
    需要验证钦件包GPG签名
    GPG key:/etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
    启用此软件仓库
    仓库2:
    Name:RH294_Stream
    Description:RH294 stream software
    Base url: http://content.example.com/rhel8.0/x86_64/dvd/AppStream
    需要验证软件包GPG签名
    GPG key:/etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
    启用此软件仓库

    1. [devops@workstation ansible]$ sudo vim adhoc.sh
    2. #!/bin/bash
    3. ansible all -m yum_repository -a 'name=RH294_Base \
    4. description="RH294 base software" \
    5. baseurl="http://content.example.com/rhel8.0/x86_64/dvd/BaseOS" \
    6. gpgcheck=yes \
    7. gpgkey=/etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release \
    8. enabled=yes'
    9. ansible all -m yum_repository -a 'name=RH294_Stream \
    10. description="RH294 stream software" \
    11. baseurl="http://content.example.com/rhel8.0/x86_64/dvd/AppStream" \
    12. gpgcheck=yes \
    13. gpgkey=/etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release \
    14. enabled=yes'
    15. [devops@workstation ansible]$ sudo chmod +x adhoc.sh
    16. [devops@workstation ansible]$ ./adhoc.sh
    17. serverb | CHANGED => {
    18. "ansible_facts": {
    19. "discovered_interpreter_python": "/usr/libexec/platform-python"
    20. },
    21. "changed": true,
    22. "repo": "RH294_Base",
    23. "state": "present"
    24. }
    25. serverc | CHANGED => {
    26. "ansible_facts": {
    27. "discovered_interpreter_python": "/usr/libexec/platform-python"
    28. },
    29. "changed": true,
    30. "repo": "RH294_Base",
    31. "state": "present"
    32. }
    33. servera | CHANGED => {
    34. "ansible_facts": {
    35. "discovered_interpreter_python": "/usr/libexec/platform-python"
    36. },
    37. "changed": true,
    38. "repo": "RH294_Base",
    39. "state": "present"
    40. }
    41. serverd | CHANGED => {
    42. "ansible_facts": {
    43. "discovered_interpreter_python": "/usr/libexec/platform-python"
    44. },
    45. "changed": true,
    46. "repo": "RH294_Base",
    47. "state": "present"
    48. }
    49. serverb | CHANGED => {
    50. "ansible_facts": {
    51. "discovered_interpreter_python": "/usr/libexec/platform-python"
    52. },
    53. "changed": true,
    54. "repo": "RH294_Stream",
    55. "state": "present"
    56. }
    57. servera | CHANGED => {
    58. "ansible_facts": {
    59. "discovered_interpreter_python": "/usr/libexec/platform-python"
    60. },
    61. "changed": true,
    62. "repo": "RH294_Stream",
    63. "state": "present"
    64. }
    65. serverd | CHANGED => {
    66. "ansible_facts": {
    67. "discovered_interpreter_python": "/usr/libexec/platform-python"
    68. },
    69. "changed": true,
    70. "repo": "RH294_Stream",
    71. "state": "present"
    72. }
    73. serverc | CHANGED => {
    74. "ansible_facts": {
    75. "discovered_interpreter_python": "/usr/libexec/platform-python"
    76. },
    77. "changed": true,
    78. "repo": "RH294_Stream",
    79. "state": "present"
    80. }
    81. [devops@workstation ansible]$ ansible all -m command -a 'ls /etc/yum.repos.d'
    82. serverd | CHANGED | rc=0 >>
    83. redhat.repo
    84. RH294_Base.repo
    85. RH294_Stream.repo
    86. rhel_dvd.repo
    87. serverc | CHANGED | rc=0 >>
    88. redhat.repo
    89. RH294_Base.repo
    90. RH294_Stream.repo
    91. rhel_dvd.repo
    92. servera | CHANGED | rc=0 >>
    93. redhat.repo
    94. RH294_Base.repo
    95. RH294_Stream.repo
    96. rhel_dvd.repo
    97. serverb | CHANGED | rc=0 >>
    98. redhat.repo
    99. RH294_Base.repo
    100. RH294_Stream.repo
    101. rhel_dvd.repo
    102. [devops@workstation ansible]$ ansible all -m command -a 'cat /etc/yum.repos.d/RH294_Base.repo'
    103. serverd | CHANGED | rc=0 >>
    104. [RH294_Base]
    105. baseurl = http://content.example.com/rhel8.0/x86_64/dvd/BaseOS
    106. enabled = 1
    107. gpgcheck = 1
    108. gpgkey = /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
    109. name = RH294 base software
    110. serverc | CHANGED | rc=0 >>
    111. [RH294_Base]
    112. baseurl = http://content.example.com/rhel8.0/x86_64/dvd/BaseOS
    113. enabled = 1
    114. gpgcheck = 1
    115. gpgkey = /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
    116. name = RH294 base software
    117. serverb | CHANGED | rc=0 >>
    118. [RH294_Base]
    119. baseurl = http://content.example.com/rhel8.0/x86_64/dvd/BaseOS
    120. enabled = 1
    121. gpgcheck = 1
    122. gpgkey = /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
    123. name = RH294 base software
    124. servera | CHANGED | rc=0 >>
    125. [RH294_Base]
    126. baseurl = http://content.example.com/rhel8.0/x86_64/dvd/BaseOS
    127. enabled = 1
    128. gpgcheck = 1
    129. gpgkey = /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
    130. name = RH294 base software
    131. [devops@workstation ansible]$ ansible all -m command -a 'cat /etc/yum.repos.d/RH294_Stream.repo'
    132. serverd | CHANGED | rc=0 >>
    133. [RH294_Stream]
    134. baseurl = http://content.example.com/rhel8.0/x86_64/dvd/AppStream
    135. enabled = 1
    136. gpgcheck = 1
    137. gpgkey = /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
    138. name = RH294 stream software
    139. serverc | CHANGED | rc=0 >>
    140. [RH294_Stream]
    141. baseurl = http://content.example.com/rhel8.0/x86_64/dvd/AppStream
    142. enabled = 1
    143. gpgcheck = 1
    144. gpgkey = /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
    145. name = RH294 stream software
    146. serverb | CHANGED | rc=0 >>
    147. [RH294_Stream]
    148. baseurl = http://content.example.com/rhel8.0/x86_64/dvd/AppStream
    149. enabled = 1
    150. gpgcheck = 1
    151. gpgkey = /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
    152. name = RH294 stream software
    153. servera | CHANGED | rc=0 >>
    154. [RH294_Stream]
    155. baseurl = http://content.example.com/rhel8.0/x86_64/dvd/AppStream
    156. enabled = 1
    157. gpgcheck = 1
    158. gpgkey = /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
    159. name = RH294 stream software

     

     

     

     

  • 相关阅读:
    LIO-SAM源码解析(五):mapOptmization.cpp
    OpenWrt KernelPackage分析
    [vmware]vmware虚拟机压缩空间清理空间
    【Spring Cloud】Eureka注册中心
    百度SEO工具,自动更新网站的工具
    HIVE源码阅读(五)
    深入探索STARK的安全性和可靠性——STARKs全面安全分析
    SpringBoot中使用注解方式拦截恶意访问的IP
    即时通讯开发Netty实现心跳机制、断线重连机制
    Vue 3 的常用响应式 API 总结
  • 原文地址:https://blog.csdn.net/weixin_64334766/article/details/133799812