当前位置:网站首页>Related operations of ansible and Playbook

Related operations of ansible and Playbook

2022-06-25 00:06:00 qq_ fifty-two million one hundred and seventy-eight thousand fi

1、 Deploy to the managed host yum Warehouse , Examples are as follows :

Warehouse 1 : Name: base ​

               Description: baseos ​                

               Base url: Index of /centos-vault/8.5.2111/BaseOS/x86_64/os/

                 Need to validate the package GPG Signature ​ GPG key stay /etc/pki/rpm-gpg/RPM-GPG-KEY-* ​

                 Enable this software repository

Warehouse 2: Name: app

               Description: appstream

               Base url: Index of /centos-vault/8.5.2111/AppStream/x86_64/os/

                Need to validate the package GPG Signature GPG key stay : /etc/pki/rpm-gpg/RPM-GPG-KEY-*

                Enable this software repository

[[email protected] test01]$ vim creat_yum.yml


---
- name: play1
  hosts: all
  tasks:
    - name: create base
      yum_repository:
        name: base
        description: baseos
        baseurl: https://mirrors.aliyun.com/centos-vault/8.2.2004/BaseOS/x86_64/os/
        gpgcheck: yes
    - name: create appstream
      yum_repository:
        name: app
        description: appstream
        baseurl: https://mirrors.aliyun.com/centos-vault/8.2.2004/AppStream/x86_64/os/
        gpgcheck: yes
    - name: install vsftpd
      yum:
        name: vsftpd
        state: latest

notes : Check your own linux System version , And select the corresponding version warehouse .

After successful deployment, install on the managed host vsftpd software package

2、 to web Host group write one playbook, The playbook There are two play, first play It can be guaranteed in web Install on host group httpd and php, Make sure web Of the host group /var/www/html/ There is a file under the directory named index.php, The contents are as follows :

$ cat /var/www/html/index.php
<?php
phpinfo();

The playbook The second one play Used to test the web Of the host group web Whether the service can be successfully accessed index.php Content .

[[email protected] test01]$ vim inventory
[[email protected] test01]$ vim 1.yml

3、 Add a normal user on the controlled node xiaohong, Users who configure the current control node can log in without secret xiaohong user , also xiaohong Sure sudo.

[[email protected] test01]$ vim 2.yml

---
- name: play1
  hosts: node01
  tasks:
    - name: useradd xiaohong
      user:
        name: xiaohong
        state: present

    - name: xiaohong sudoers
      lineinfile:
        line: "xiaohong ALL=(ALL) NOPASSWD:ALL"
        path: /etc/sudoers
    - authorized_key:
        state: present
        user: xiaohong
        key: "{
   { lookup('file', '/home/admin/.ssh/id_rsa.pub') }}"

原网站

版权声明
本文为[qq_ fifty-two million one hundred and seventy-eight thousand fi]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/175/202206241908056913.html