Я новичок в Ansible, поэтому будем благодарны за любые советы.
Я использую ansible 2.9.10.
Прежде всего
На моем управляющем узле я создал playbook, в котором я настроил управляющий хост в качестве хоста репозитория: установочный ISO RHEL 8 должен быть установлен в цикле в каталоге / var / ftp / repo, firewalld
служба отключена и vsftpd
служба запущена и включена, и позволяет анонимному пользователю получить доступ к каталогу / var / ftp / repo
---
- name: Setup control host as repository host
hosts: localhost
become: true
vars:
anonymous_enable: yes
tasks:
- name: Install vsftpd
yum:
name: vsftpd
state: latest
- name: Start and enable vsftpd service
service:
name: vsftpd
state: started
enabled: true
- name: Disable firewall
firewalld:
service: firewall
state: disabled
- name: Allow anonymous user access to /var/ftp/repo
template:
src: templates/vsftpd.j2/v.j2
dest: /etc/vsftpd/vsftpd.conf
- name: Setup repo directory
file:
path: /var/ftp/repo
state: directory
- name: create repo
mount:
path: /var/ftp/repo
src: /dev/sr0
fstype: iso9660
opts: loop,ro
state: mounted
следующий
Я управляю узлом и хочу настроить его в качестве клиента репозитория для сервера репозитория, который был настроен выше в предыдущем примере. Я хочу использовать специальную команду, чтобы разрешить доступ к репозиториям BaseOS и AppStream на моем контрольном узле. Ниже этой команды и возвращенный результат:
[ansible@control ~]$ ansible ansible1 -u root --ask-pass -m yum_repository -a "name=AppStream file=AppStream baseurl=ftp://control.example.com/repo/AppStream/ description=AppStream gpgcheck=no enabled=yes state=present"
SSH password:
ansible1 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/libexec/platform-python"
},
"changed": true,
"repo": "AppStream",
"state": "present"
}
[ansible@control ~]$ ansible ansible1 -u root --ask-pass -m yum_repository -a "name=BaseOS file=BaseOS baseurl=ftp://control.example.com/repo/ description=BaseOS gpgcheck=no enabled=yes state=present"
SSH password:
ansible1 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/libexec/platform-python"
},
"changed": true,
"repo": "BaseOS",
"state": "present"
Похоже, что все в порядке, НО когда я вхожу в управляемый узел и пытаюсь сделать ням реполист, я получил:
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
AppStream 0.0 B/s | 0 B 00:01
BaseOS 0.0 B/s | 0 B 00:01
Failed to synchronize cache for repo 'AppStream', ignoring this repo.
Failed to synchronize cache for repo 'BaseOS', ignoring this repo.
Затем я подписал систему с помощью диспетчера подписки rhel, но снова, когда я вхожу в управляемый узел и пытаюсь выполнить реполистирование yum, я получил точно такую же ошибку (в отношении моих локальных репозиториев на управляющем узле в / var / каталог ftp / репо):
Updating Subscription Management repositories.
AppStream 0.0 B/s | 0 B 00:01
BaseOS 0.0 B/s | 0 B 00:01
Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs) 3.2 kB/s | 4.5 kB 00:01
Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs) 2.8 kB/s | 4.1 kB 00:01
Failed to synchronize cache for repo 'AppStream', ignoring this repo.
Failed to synchronize cache for repo 'BaseOS', ignoring this repo.
repo id repo name status
rhel-8-for-x86_64-appstream-rpms Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs) 10,766
rhel-8-for-x86_64-baseos-rpms Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs) 4,834
Мне нужно использовать локальное репо в / var / ftp / repo, пожалуйста, помогите мне понять, где я ошибался! Кроме того, когда я пытался установить пакет pkg с помощью специальной команды, я получаю сообщение об ошибке:
[ansible@control ~]$ ansible ansible1 -u root --ask-pass -m yum -a "name=httpd state=latest"
SSH password:
ansible1 | FAILED! => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/libexec/platform-python"
},
"changed": false,
"failures": [
"No package httpd available."
],
"msg": "Failed to install some of the specified packages",
"rc": 1,
"results": []
Информация о FTP:
[ansible@control ~]$ ls /var/ftp/repo/
AppStream EFI extra_files.json images media.repo RPM-GPG-KEY-redhat-release
BaseOS EULA GPL isolinux RPM-GPG-KEY-redhat-beta TRANS.TBL
[ansible@control ~]$ systemctl status vsftpd
● vsftpd.service - Vsftpd ftp daemon
Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2020-07-01 22:02:01 EEST; 50min ago
Process: 1055 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf (code=exited, status=0/SUCCESS)
Main PID: 1059 (vsftpd)
Tasks: 1 (limit: 4915)
Memory: 344.0K
CGroup: /system.slice/vsftpd.service
└─1059 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf
Файлы репо для содержимого управляемых узлов:
[ansible@control ~]$ ansible ansible1 -m command -a "cat /etc/yum.repos.d/AppStream.repo"
ansible1 | CHANGED | rc=0 >>
[AppStream]
baseurl = ftp://control.example.com/repo/
enabled = 1
gpgcheck = 0
name = AppStream
[ansible@control ~]$ ansible ansible1 -m command -a "cat /etc/yum.repos.d/BaseOS.repo"
ansible1 | CHANGED | rc=0 >>
[BaseOS]
baseurl = ftp://control.example.com/repo/
enabled = 1
gpgcheck = 0
name = BaseOS
Вы не можете устанавливать пакеты, пока не получите подписался на систему и получил право.
Вы можете сделать это с помощью модуль redhat_subscription. После регистрации вы можете использовать модуль rhsm_repository чтобы включить нужные репозитории.
Вот как я регистрирую свои системы RHEL и включаю желаемые репозитории RHEL:
---
- hosts: all
gather_facts: True
tasks:
- name: "Group by operating system"
group_by:
key: os_{{ ansible_distribution }}
- hosts: os_RedHat
gather_facts: True
# Registering the system and enabling repos must come first,
# before installing packages
pre_tasks:
- block:
- name: Register RHEL system
redhat_subscription:
activationkey: "Ansible_Provisioned"
org_id: "*******"
auto_attach: True
- name: Enable RHEL repos (RHEL 7)
rhsm_repository: name={{item}} state=enabled
with_items:
- rhel-{{ansible_distribution_major_version}}-server-rpms
- rhel-{{ansible_distribution_major_version}}-server-extras-rpms
- rhel-{{ansible_distribution_major_version}}-server-optional-rpms
when: ansible_distribution_major_version|int <= 7
- name: Enable RHEL repos (RHEL 8)
rhsm_repository: name={{item}} state=enabled
with_items:
- rhel-{{ansible_distribution_major_version}}-for-{{ansible_architecture}}-baseos-rpms
- rhel-{{ansible_distribution_major_version}}-for-{{ansible_architecture}}-appstream-rpms
- rhel-{{ansible_distribution_major_version}}-for-{{ansible_architecture}}-supplementary-rpms
- codeready-builder-for-rhel-{{ansible_distribution_major_version}}-{{ansible_architecture}}-rpms
when: ansible_distribution_major_version|int == 8
- name: Disable RHEL repos (RHEL 7)
rhsm_repository: name={{item}} state=disabled
with_items:
- rhel-{{ansible_distribution_major_version}}-server-rt-rpms
- rhel-{{ansible_distribution_major_version}}-server-rt-beta-rpms
when: ansible_distribution_major_version|int <= 7
when: ansible_distribution == 'RedHat'
roles:
- redhatinsights.insights-client
Обратите внимание: если вы пытаетесь установить пакеты в автономном режиме, вам придется временно (или навсегда) отключить онлайн-репозитории Red Hat во время установки пакета. Например:
- name: Install httpd
dnf:
name: httpd
disablerepo: rhel-8-for-x86_64-appstream-rpms,rhel-8-for-x86_64-baseos-rpms
Также похоже, что ваши пользовательские репозитории BaseOS и AppStream на самом деле недоступны с вашего нового узла, поэтому вам также следует разобраться с этим.