RHCE8.2

RHCE8.2

Install and configure Ansible

安装和配置 Ansible

按照下方所述,在控制节点 control 上安装和配置 Ansible:

    安装所需的软件包

    创建名为 /home/greg/ansible/inventory 的静态清单文件,以满足以下要求:

        node1 是 dev 主机组的成员

        node2 是 test 主机组的成员

        node3 和 node4 是 prod 主机组的成员

        node5 是 balancers 主机组的成员

        prod 组是 webservers 主机组的成员

    创建名为 /home/greg/ansible/ansible.cfg 的配置文件,以满足以下要求:

        主机清单文件为 /home/greg/ansible/inventory

        playbook 中使用的角色的位置包括 /home/greg/ansible/roles
[kiosk@foundation0 ~]$ ssh greg@control
[greg@control ~]$ sudo yum install -y ansible
[greg@control ~]$ mkdir -p /home/greg/ansible/roles
[greg@control ~]$ cd ansible/
[greg@control ansible]$ vim /home/greg/ansible/inventory 
[greg@control ansible]$ cat /home/greg/ansible/inventory 
[dev]
node1

[test]
node2

[prod]
node3
node4

[balancers]
node5

[webservers:children]
prod
[greg@control ansible]$ cp /etc/ansible/ansible.cfg  .
[greg@control ansible]$ vim ansible.cfg 

inventory = /home/greg/ansible/inventory #在命令模式⽤/ 区查找第⼀个单词,进⾏
roles_path = /home/greg/ansible/roles #修改⽬录
取消ssh验证,也就是第⼀次ssh机器时不需要按yes更新密钥
host_key_checking = False #取消注释
remote_user = greg #取消注释,修改⽤⼾
[privilege_escalation] #查找privi,然后按n往下翻,将注释打开
become=True
become_method=sudo
become_user=root
become_ask_pass=False
[greg@control ansible]$ ansible all --list
  hosts (5):
    node1
    node2
    node5
    node3
    node4

Create and run Ansible ad-hoc commands

创建和运行 Ansible 临时命令

作为系统管理员,您需要在受管节点上安装软件。

请按照正文所述,创建一个名为 /home/greg/ansible/adhoc.sh 的 shell 脚本,该脚本将使用 Ansible 临时命令在各个受管节点上安装 yum 存储库:

存储库1:

    存储库的名称为 EX294_BASE

    描述为 EX294 base software

    基础 URL 为 http://content/rhel8.0/x86_64/dvd/BaseOS

    GPG 签名检查为启用状态

    GPG 密钥 URL 为 http://content/rhel8.0/x86_64/dvd/RPM-GPG-KEY-redhat-release

    存储库为启用状态

存储库2:

    存储库的名称为 EX294_STREAM

    描述为 EX294 stream software

    基础 URL 为 http://content/rhel8.0/x86_64/dvd/AppStream

    GPG 签名检查为启用状态

    GPG 密钥 URL 为 http://content/rhel8.0/x86_64/dvd/RPM-GPG-KEY-redhat-release

    存储库为启用状态
#不清楚模块参数使用  shift+G到最后看样例
[greg@control ansible]$ ansible-doc yum_repository

[greg@control ansible]$ vim /home/greg/ansible/adhoc.sh
[greg@control ansible]$ cat /home/greg/ansible/adhoc.sh
#!/bin/bash
ansible all -m yum_repository -a "name='EX294_BASE' description='EX294 base software' baseurl='http://content/rhel8.0/x86_64/dvd/BaseOS' gpgcheck=yes
gpgkey='http://content/rhel8.0/x86_64/dvd/RPM-GPG-KEY-redhat-release' enabled=yes"
ansible all -m yum_repository -a "name='EX294_STREAM' description='EX294 stream software' baseurl='http://content/rhel8.0/x86_64/dvd/AppStream' gpgcheck=yes
gpgkey='http://content/rhel8.0/x86_64/dvd/RPM-GPG-KEY-redhat-release' enabled=yes"
[greg@control ansible]$ chmod +x /home/greg/ansible/adhoc.sh
[greg@control ansible]$ ./adhoc.sh 

Install packages

安装软件包

创建一个名为 /home/greg/ansible/packages.yml 的 playbook :

    将 php 和 mariadb 软件包安装到 dev、test 和 prod 主机组中的主机上

    将 RPM Development Tools 软件包组安装到 dev 主机组中的主机上

    将 dev 主机组中主机上的所有软件包更新为最新版本
[greg@control ansible]$ vim /home/greg/ansible/packages.yml
[greg@control ansible]$ cat  /home/greg/ansible/packages.yml
#yaml文件每个层级之间为2个空格
---
- name: php 和 mariadb
  hosts: dev,test,prod
  tasks:
  - name: php 和 mariadb
    yum:
      name: php,mariadb
      state: present

- name: install dev
  hosts: dev
  tasks:
  - name: RPM Development Tools
    yum:
      name: "@RPM Development Tools"
      state: present
  - name: 软件包更新为最新版本
    yum: 
      name: '*'
      state: latest  
[greg@control ansible]$ ansible-playbook packages.yml 

Using RHEL system roles

使用 RHEL 系统角色

安装 RHEL 系统角色软件包,并创建符合以下条件的 playbook /home/greg/ansible/timesync.yml :

    在所有受管节点上运行

    使用 timesync 角色

    配置该角色,以使用当前有效的 NTP 提供商

    配置该角色,以使用时间服务器 172.25.254.254

    配置该角色,以启用 iburst 参数
[greg@control ansible]$ yum search roles
Last metadata expiration check: 0:00:38 ago on Fri 01 Sep 2023 09:33:50 PM GMT.
============================= Name Matched: roles ==============================
rhel-system-roles.noarch : Set of interfaces for unified system management
[greg@control ansible]$ sudo yum -y install rhel-system-roles
[greg@control ansible]$ vim ansible.cfg 
[greg@control ansible]$ grep roles_path ansible.cfg 
roles_path    = /home/greg/ansible/roles:/usr/share/ansible/roles

[greg@control ansible]$ ansible-galaxy list
# /home/greg/ansible/roles
# /usr/share/ansible/roles
- linux-system-roles.kdump, (unknown version)
- linux-system-roles.network, (unknown version)
- linux-system-roles.postfix, (unknown version)
- linux-system-roles.selinux, (unknown version)
- linux-system-roles.timesync, (unknown version)
- rhel-system-roles.kdump, (unknown version)
- rhel-system-roles.network, (unknown version)
- rhel-system-roles.postfix, (unknown version)
- rhel-system-roles.selinux, (unknown version)
- rhel-system-roles.timesync, (unknown version)

[greg@control ansible]$ cp /usr/share/doc/rhel-system-roles/timesync/example-timesync-playbook.yml /home/greg/ansible/timesync.yml
[greg@control ansible]$ vim timesync.yml 
[greg@control ansible]$ cat timesync.yml 
---
- hosts: all
  vars:
    timesync_ntp_servers:
      - hostname: 172.25.254.254
        iburst: yes
  roles:
    - rhel-system-roles.timesync
[greg@control ansible]$ ansible-playbook timesync.yml 

Ansible Galaxy installation role

使用 Ansible Galaxy 安装角色

使用 Ansible Galaxy 和要求文件 /home/greg/ansible/roles/requirements.yml 。从以下 URL 下载角色并安装到 /home/greg/ansible/roles :

    http://materials/haproxy.tar 此角色的名称应当为 balancer

    http://materials/phpinfo.tar 此角色的名称应当为 phpinfo
[greg@control ansible]$ vim /home/greg/ansible/roles/requirements.yml 
[greg@control ansible]$ cat /home/greg/ansible/roles/requirements.yml 
---
- src: http://materials/haproxy.tar
  name: balancer

- src: http://materials/phpinfo.tar
  name: phpinfo  
[greg@control ansible]$ ansible-galaxy install -r /home/greg/ansible/roles/requirements.yml -p /home/greg/ansible/roles
- downloading role from http://materials/haproxy.tar
- extracting balancer to /home/greg/ansible/roles/balancer
- balancer was installed successfully
- downloading role from http://materials/phpinfo.tar
- extracting phpinfo to /home/greg/ansible/roles/phpinfo
- phpinfo was installed successfully
[greg@control ansible]$ ansible-galaxy list
# /home/greg/ansible/roles
- balancer, (unknown version)
- phpinfo, (unknown version)
# /usr/share/ansible/roles
- linux-system-roles.kdump, (unknown version)
- linux-system-roles.network, (unknown version)
- linux-system-roles.postfix, (unknown version)
- linux-system-roles.selinux, (unknown version)
- linux-system-roles.timesync, (unknown version)
- rhel-system-roles.kdump, (unknown version)
- rhel-system-roles.network, (unknown version)
- rhel-system-roles.postfix, (unknown version)
- rhel-system-roles.selinux, (unknown version)
- rhel-system-roles.timesync, (unknown version)

Create and use roles

创建和使用角色

根据下列要求,在 /home/greg/ansible/roles 中创建名为 apache 的角色:

    httpd 软件包已安装,设为在系统启动时启用并启动

    防火墙已启用并正在运行,并使用允许访问 Web 服务器的规则

    模板文件 index.html.j2 已存在,用于创建具有以下输出的文件 /var/www/html/index.html :

    Welcome to HOSTNAME on IPADDRESS

    其中,HOSTNAME 是受管节点的完全限定域名,IPADDRESS 则是受管节点的 IP 地址。
[greg@control ansible]$ cd /home/greg/ansible/roles
[greg@control roles]$ ansible-galaxy init apache
- apache was created successfully
[greg@control roles]$ vim apache/tasks/main.yml 
[greg@control roles]$ cat apache/tasks/main.yml 
---
# tasks file for apache
- name: httpd 软件包已安装
  yum:
    name: httpd
    state: present

- name: httpd 设为在系统启动时启用并启动
  service: 
    name: httpd
    state: started
    enabled: yes

- name: 防火墙已启用并正在运行
  service:
    name: firewalld
    state: started
    enabled: yes

- name: 并使用允许访问 Web 服务器的规则
  firewalld:
    service: http
    permanent: yes
    state: enabled
    immediate: yes

- name: 模板文件 index.html.j2 已存在,用于创建具有以下输出的文件    
  template:
    src: index.html.j2
    dest: /var/www/html/index.html    
[greg@control roles]$ vim apache/templates/index.html.j2
[greg@control roles]$ cat  apache/templates/index.html.j2
Welcome to {
    
    {
    
     ansible_fqdn }} on {
    
    {
    
     ansible_default_ipv4.address }}

Using roles from Ansible Galaxy

从 Ansible Galaxy 使用角色

根据下列要求,创建一个名为 /home/greg/ansible/roles.yml 的 playbook :

    playbook 中包含一个 play, 该 play 在 balancers 主机组中的主机上运行并将使用 balancer 角色。

        此角色配置一项服务,以在 webservers 主机组中的主机之间平衡 Web 服务器请求的负载。

        浏览到 balancers 主机组中的主机(例如 http://172.25.250.13 )将生成以下输出:

        Welcome to serverb.lab.example.com on 172.25.250.11

        重新加载浏览器将从另一 Web 服务器生成输出:

        Welcome to serverc.lab.example.com on 172.25.250.12

    playbook 中包含一个 play, 该 play 在 webservers 主机组中的主机上运行并将使用 phpinfo 角色。

        请通过 URL /hello.php 浏览到 webservers 主机组中的主机将生成以下输出:

        Hello PHP World from FQDN

        其中,FQDN 是主机的完全限定名称。

        Hello PHP World from serverb.lab.example.com

另外还有 PHP 配置的各种详细信息,如安装的 PHP 版本等。

    同样,浏览到 http://172.25.250.12/hello.php 会生成以下输出:

    Hello PHP World from serverc.lab.example.com

 另外还有 PHP 配置的各种详细信息,如安装的 PHP 版本等。
---
- name: webservers 主机组中的主机上运行并将使用 phpinfo
  hosts: webservers
  roles:
  - phpinfo
  - apache

- name: balancers 主机组中的主机上运行并将使用 balancer 角色
  hosts: balancers
  roles:
  - balancer

Create and use logical volumes

创建和使用逻辑卷

创建一个名为 /home/greg/ansible/lv.yml 的 playbook ,它将在所有受管节点上运行以执行下列任务:

    创建符合以下要求的逻辑卷:

        逻辑卷创建在 research 卷组中

        逻辑卷名称为 data

        逻辑卷大小为 1500 MiB

    使用 ext4 文件系统格式化逻辑卷

    如果无法创建请求的逻辑卷大小,应显示错误信息

    Could not create logical volume of that size

     ,并且应改为使用大小 800 MiB。

    如果卷组 research 不存在,应显示错误信息

    Volume group done not exist

    。

    不要以任何方式挂载逻辑卷
---
- name: 创建符合以下要求的逻辑卷
  hosts: all
  tasks:
  - block:
    - name: 逻辑卷创建在 research 卷组中名称为 data 大小为 1500 MiB
      lvol:
        vg: research
        lv: data
        size: 1500
    - name: 使用 ext4 文件系统格式化逻辑卷
      filesystem:
        fstype: ext4
        dev: /dev/research/data
    rescue:
    - debug:
        msg: Could not create logical volume of that size
    - name: 改为使用大小 800 MiB
      lvol:
        vg: research
        lv: data
        size: 800
      when: ansible_lvm.vgs.research is defined
    - name: 使用 ext4 文件系统格式化逻辑卷
      filesystem:
        fstype: ext4
        dev: /dev/research/data
      when: ansible_lvm.vgs.research is defined
      ignore_errors: yes
    - debug:
        msg: Volume group done not exist
      when: ansible_lvm.vgs.research is undefined

Generate hosts file

生成主机文件

    将一个初始模板文件从 http://materials/hosts.j2 下载到 /home/greg/ansible

    完成该模板,以便用它生成以下文件:针对每个清单主机包含一行内容,其格式与 /etc/hosts 相同

    创建名为 /home/greg/ansible/hosts.yml 的 playbook ,它将使用此模板在 dev 主机组中的主机上生成文件 /etc/myhosts 。

该 playbook 运行后, dev 主机组中主机上的文件 /etc/myhosts 应针对每个受管主机包含一行内容:

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4

::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

​

172.25.250.9    node1.lab.example.com node1

172.25.250.10   node2.lab.example.com node2

172.25.250.11   node3.lab.example.com node3

172.25.250.12   node4.lab.example.com node4

172.25.250.13   node5.lab.example.com node5

注:清单主机名称的显示顺序不重要。
[greg@control ansible]$ wget http://materials/hosts.j2
[greg@control ansible]$ cat hosts.j2 
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

{
    
    % for host in groups['all'] %}
{
    
    {
    
     hostvars[host]['ansible_facts']['default_ipv4']['address'] }} {
    
    {
    
    
hostvars[host]['ansible_facts']['fqdn'] }} {
    
    {
    
     hostvars[host]['ansible_facts']
['hostname'] }}
{
    
    % endfor %}
---
- name: 生成文件 /etc/myhosts
  hosts: all
  tasks:
  - name: 生成文件 /etc/myhosts
    template:
      src: /home/greg/ansible/hosts.j2
      dest: /etc/myhosts
    when: inventory_hostname in groups['dev']      

Modify file content

修改文件内容

按照下方所述,创建一个名为 /home/greg/ansible/issue.yml 的 playbook :

    该 playbook 将在所有清单主机上运行

    该 playbook 会将 /etc/issue 的内容替换为下方所示的一行文本:

        在 dev 主机组中的主机上,这行文本显示 为:Development

        在 test 主机组中的主机上,这行文本显示 为:Test

        在 prod 主机组中的主机上,这行文本显示 为:Production
---
- name: 修改文件内容
  hosts: all
  tasks:
  - name: 在 dev 主机组中的主机上,这行文本显示 为:Development
    copy:
      content: "Development"
      dest: /etc/issue
    when: inventory_hostname in groups.dev
  - name: 在 test 主机组中的主机上,这行文本显示 为:Test
    copy:
      content: "Test"
      dest: /etc/issue
    when: inventory_hostname in groups.test
  - name: 在 prod 主机组中的主机上,这行文本显示 为:Production
    copy:
      content: "Production"
      dest: /etc/issue
    when: inventory_hostname in groups.prod

Create a web content directory

创建 Web 内容目录

按照下方所述,创建一个名为 /home/greg/ansible/webcontent.yml 的 playbook :

    该 playbook 在 dev 主机组中的受管节点上运行

    创建符合下列要求的目录 /webdev :

        所有者为 webdev 组

        具有常规权限:owner=read+write+execute , group=read+write+execute ,other=read+execute

        具有特殊权限:设置组 ID

    用符号链接将 /var/www/html/webdev 链接到 /webdev

    创建文件 /webdev/index.html ,其中包含如下所示的单行文件: Development

    在 dev 主机组中主机上浏览此目录(例如 http://172.25.250.9/webdev/ )将生成以下输出:

    Development
---
- name: 创建 Web 内容目录
  hosts: dev
  tasks:
  - name: 目录 /webdev
    file: 
      path: /webdev
      group: webdev
      mode: "2775"
      setype: httpd_sys_content_t
      state: directory
  - name: 用符号链接将 /var/www/html/webdev 链接到 /webdev
    file:
      src: /webdev
      dest: /var/www/html/webdev 
      state: link
  - name: 创建文件 /webdev/index.html
    copy:
      content: "Development"
      dest: /webdev/index.html
      setype: httpd_sys_content_t
  - name: http
    service: 
      name: httpd
      state: started
      enabled: yes
  - name: firewalld
    service:
      name: firewalld
      state: started
      enabled: yes
  - name: firewall open
    firewalld:
      service: http
      permanent: yes
      state: enabled
      immediate: yes      

Generate hardware report

生成硬件报告

创建一个名为 /home/greg/ansible/hwreport.yml 的 playbook ,它将在所有受管节点上生成含有以下信息的输出文件 /root/hwreport.txt :

    清单主机名称

    以 MB 表示的总内存大小

    BIOS 版本

    磁盘设备 vda 的大小

    磁盘设备 vdb 的大小

    输出文件中的每一行含有一个 key=value 对。

您的 playbook 应当:

    从 http://materials/hwreport.empty 下载文件,并将它保存为 /root/hwreport.txt

    使用正确的值改为 /root/hwreport.txt

    如果硬件项不存在,相关的值应设为 NONE
#通过setup模块获取参数信息

[greg@control ansible]$ ansible -m setup | grep hostname
ERROR! Missing target hosts
[greg@control ansible]$ ansible -m setup dev | grep hostname 
        "ansible_hostname": "node1",
[greg@control ansible]$ ansible -m setup dev | grep mem
        "ansible_memfree_mb": 676,
        "ansible_memory_mb": {
    
    
        "ansible_memtotal_mb": 1829,
[greg@control ansible]$ ansible -m setup dev | grep bios
        "ansible_bios_date": "04/01/2014",
        "ansible_bios_version": "1.11.1-3.module+el8+2529+a9686a4d",

[greg@control ansible]$ ansible -m setup test | grep device
        "ansible_device_links": {
    
    
        "ansible_devices": {
    
    
                "sas_device_handle": null,
                "host": "SCSI storage controller: Red Hat, Inc. Virtio block device (rev 01)",
                "sas_device_handle": null,
                "host": "SCSI storage controller: Red Hat, Inc. Virtio block device (rev 01)",
                "sas_device_handle": null,
            "device": "enp1s0",
            "device": "enp2s0",
            "device": "lo",
                "device": "/dev/vda1",
---
- name: hw report
  hosts: all
  vars:
    hw_all:
    - hw_name: HOST
      hw_cont: "{
    
    { inventory_hostname | default('NONE', true) }}"
    - hw_name: MEMORY
      hw_cont: "{
    
    { ansible_memtotal_mb | default('NONE', true) }}"
    - hw_name: BIOS
      hw_cont: "{
    
    { ansible_bios_version | default('NONE', true) }}"
    - hw_name: DISK_SIZE_VDA
      hw_cont: "{
    
    { ansible_devices.vda.size | default('NONE', true) }}"
    - hw_name: DISK_SIZE_VDB
      hw_cont: "{
    
    { ansible_devices.vdb.size | default('NONE', true) }}"
  tasks:
  - name: download hw_temp
    get_url:
      url: "http://materials.example.com/hwreport.empty"
      dest: /root/hwreport.txt
  - name: generate hw report
    lineinfile:
      path: /root/hwreport.txt
      regexp: "^{
    
    { item.hw_name }}="
      line: "{
    
    { item.hw_name }}={
    
    { item.hw_cont }}"
    loop: "{
    
    { hw_all }}"  

Create password library

创建密码库

按照下方所述,创建一个 Ansible 库来存储用户密码:

    库名称为 /home/greg/ansible/locker.yml

    库中含有两个变量,名称如下:

        pw_developer,值为 Imadev

        pw_manager,值为 Imamgr

    用于加密和解密该库的密码为 whenyouwishuponastar

    密码存储在文件 /home/greg/ansible/secret.txt 中
[greg@control ansible]$ grep vault  ansible.cfg 
# specifying --vault-password-file on the command line.
vault_password_file = /home/greg/ansible/secret.txt
---
pw_developer: Imadev
pw_manager: lmamgr
[greg@control ansible]$ echo "whenyouwishuponastar" > /home/greg/ansible/secret.txt
[greg@control ansible]$ ansible-vault encrypt locker.yml 
Encryption successful
[greg@control ansible]$ cat locker.yml 
$ANSIBLE_VAULT;1.1;AES256
31303133313737313138623831353562663333623533666534306565383864336332356364376631
3830306365636238643435633138623233663938336235360a373463393437666633646232613135
37346664636165383432643331366361303538363835653636623838303161316339383862653666
6436336232356466370a643663643464626362613237623662613563343334346332646435656131
34393661366534653661353066326232356338623334313133393163623064303063393463386162
6265306232363066326238623333313662303334666236633832 

[greg@control ansible]$ ansible-vault view locker.yml 
---
pw_developer: Imadev
pw_manager: lmamgr

Create user account

创建用户帐户

    从 http://materials/user_list.yml 下载要创建的用户的列表,并将它保存到 /home/greg/ansible

    在本次考试中使用在其他位置创建的密码库 /home/greg/ansible/locker.yml 。创建名为 /home/greg/ansible/users.yml 的 playbook ,从而按以下所述创建用户帐户:

        职位描述为 developer 的用户应当:

            在 dev 和 test 主机组中的受管节点上创建

            从 pw_developer 变量分配密码

            是补充组 devops 的成员

        职位描述为 manager 的用户应当:

            在 prod 主机组中的受管节点上创建

            从 pw_manager 变量分配密码

            是补充组 opsmgr 的成员

    密码采用 SHA512 哈希格式。

    您的 playbook 应能够在本次考试中使用在其他位置创建的库密码文件 /home/greg/ansible/secret.txt 正常运行。
---
- name: create user for dev,test
  hosts: dev,test
  vars_files: #变量名
  - /home/greg/ansible/locker.yml #值1 密码库⽂件
  - /home/greg/ansible/user_list.yml #值2 ⽤⼾⽂件
  tasks:
  - name: create group1
    group: #group组管理模块
      name: devops #组名 devops
      state: present #状态 创建
  - name: create user1
    user: #user⽤⼾管理模块
      name: "{
    
    { item.name }}" #创建⽤⼾,⽤⼾名从变量中取
      groups: devops #附加组 devops
      password: "{
    
    { pw_developer | password_hash('sha512') }}" #密码 pw_de
      append: yes #配合groups使⽤,追加附属组
   loop: "{
    
    { users }}" #循环变量
   when: item.job == 'developer' #描述
- name: create user for prod
  hosts: prod
  vars_files:
  - /home/greg/ansible/locker.yml
  - /home/greg/ansible/user_list.yml
  tasks:
  - name: create group2
    group:
      name: opsmgr
      state: present
  - name: create user2
    user:
      name: "{
    
    { item.name }}"
      groups: opsmgr
      password: "{
    
    { pw_manager | password_hash('sha512') }}"
      append: yes
    loop: "{
    
    { users }}"
    when: item.job == 'manager'

Ansible library key

更新 Ansible 库的密钥

按照下方所述,更新现有 Ansible 库的密钥:

    从 http://materials/salaries.yml 下载 Ansible 库到 /home/greg/ansible

    当前的库密码为 insecure8sure

    新的库密码为 bbs2you9527

    库使用新密码保持加密状态
 wget http://materials/salaries.yml #下载密码库⽂件
 #注释密码存放位置ansible配置⽂件:/vault,才能更改密码,指定⽂件位置和修改密码⽂件位置,
所以需要注释密码存放位置
 vim ansible.cfg
 #vault_password_file = /home/greg/ansible/secret.txt
ansible-vault rekey salaries.yml #更新密码库 密码
 insecure8sure #输⼊密码
bbs2you9527 #新密码输⼊2次
 ansible-vault view salaries.yml #查看密码库 密码
 #密码更改完,恢复原样
 vim ansible.cfg
 vault_password_file = /home/greg/ansible/secret.txt

Guess you like

Origin blog.csdn.net/weixin_51882166/article/details/132701209