- Создана новая роль repo для добавления репозиториев на все ОС - Добавлена поддержка Docker, PostgreSQL, Elasticsearch, Patroni репозиториев - Реализована специальная поддержка российских дистрибутивов: - Astra Linux: добавлены репозитории Lab50 и debian-archive-keyring - Alt Linux: добавлены репозитории Sisyphus (alt-sisyphus, classic, contrib) и Autoimports - Обновлена документация README.md с информацией о новой роли - Обновлен .ansible-lint для подавления необходимых правил - Автор: Сергей Антропов, https://devops.org.ru
100 lines
3.8 KiB
YAML
100 lines
3.8 KiB
YAML
---
|
||
# Задачи для RHEL/CentOS/AlmaLinux/Rocky
|
||
# Автор: Сергей Антропов
|
||
# Сайт: https://devops.org.ru
|
||
|
||
- name: Установить необходимые пакеты для работы с репозиториями (yum)
|
||
ansible.builtin.package:
|
||
name: yum-utils
|
||
state: present
|
||
when: ansible_pkg_mgr == 'yum'
|
||
|
||
- name: Установить необходимые пакеты для работы с репозиториями (dnf)
|
||
ansible.builtin.package:
|
||
name: dnf-plugins-core
|
||
state: present
|
||
when: ansible_pkg_mgr == 'dnf'
|
||
|
||
- name: Установить EPEL repository
|
||
ansible.builtin.dnf:
|
||
name: epel-release
|
||
state: present
|
||
when: ansible_distribution in ['RedHat', 'Rocky', 'CentOS', 'AlmaLinux']
|
||
|
||
- name: Определить корректный ключ для RHEL/CentOS 8
|
||
ansible.builtin.set_fact:
|
||
rhel_key: "{{ rhel_repos['rhel8'] }}"
|
||
when: ansible_distribution_major_version == "8" and os_version_id in ["redhat8", "rhel8", "centos8", "almalinux8"]
|
||
|
||
- name: Определить корректный ключ для RHEL/CentOS 9
|
||
ansible.builtin.set_fact:
|
||
rhel_key: "{{ rhel_repos['rhel9'] }}"
|
||
when: ansible_distribution_major_version == "9" and os_version_id in ["redhat9", "rhel9", "centos9", "rocky9"]
|
||
|
||
- name: Добавить репозиторий Docker
|
||
ansible.builtin.yum_repository:
|
||
name: docker-ce
|
||
description: Docker CE Repository
|
||
baseurl: "{{ rhel_key['docker_baseurl'] }}"
|
||
gpgcheck: yes
|
||
gpgkey: "{{ rhel_key['docker_gpgkey'] }}"
|
||
enabled: yes
|
||
when: rhel_key is defined
|
||
notify: "update dnf cache"
|
||
|
||
- name: Добавить репозиторий PostgreSQL
|
||
ansible.builtin.yum_repository:
|
||
name: postgresql
|
||
description: PostgreSQL Official Repository
|
||
baseurl: "{{ rhel_key['postgresql_baseurl'] }}"
|
||
gpgcheck: yes
|
||
gpgkey: "{{ rhel_key['postgresql_gpgkey'] }}"
|
||
enabled: yes
|
||
when: rhel_key is defined
|
||
notify: "update dnf cache"
|
||
|
||
- name: Добавить репозиторий Elasticsearch
|
||
ansible.builtin.yum_repository:
|
||
name: elasticsearch
|
||
description: Elasticsearch Repository
|
||
baseurl: "{{ rhel_key['elasticsearch_baseurl'] }}"
|
||
gpgcheck: yes
|
||
gpgkey: "{{ rhel_key['elasticsearch_gpgkey'] }}"
|
||
enabled: yes
|
||
when: rhel_key is defined
|
||
notify: "update dnf cache"
|
||
|
||
- name: Получить скрипт установки Patroni repository для RHEL/CentOS
|
||
ansible.builtin.get_url:
|
||
url: "https://packagecloud.io/install/repositories/patroni/patroni/script.rpm.sh"
|
||
dest: /tmp/patroni-repo-install.sh
|
||
mode: '0755'
|
||
|
||
- name: Запустить скрипт установки Patroni repository
|
||
ansible.builtin.command: bash /tmp/patroni-repo-install.sh
|
||
args:
|
||
creates: /etc/yum.repos.d/patroni_patroni.repo
|
||
notify: "update dnf cache"
|
||
|
||
- name: Очистить временный файл установки Patroni
|
||
ansible.builtin.file:
|
||
path: /tmp/patroni-repo-install.sh
|
||
state: absent
|
||
|
||
- name: Обновить кэш пакетов после добавления всех репозиториев
|
||
ansible.builtin.command: "{{ ansible_pkg_mgr }} makecache"
|
||
register: cache_result
|
||
changed_when: "'Complete!' in cache_result.stdout or 'Metadata cache created.' in cache_result.stdout"
|
||
|
||
- name: Выполнить обновление пакетов через dnf
|
||
ansible.builtin.command: dnf upgrade -y
|
||
register: dnf_upgrade
|
||
changed_when: "'Complete!' in dnf_upgrade.stdout or 'Nothing to do.' not in dnf_upgrade.stdout"
|
||
when: ansible_pkg_mgr == "dnf"
|
||
|
||
- name: Выполнить обновление пакетов через yum
|
||
ansible.builtin.command: yum upgrade -y
|
||
register: yum_upgrade
|
||
changed_when: "'Complete!' in yum_upgrade.stdout or 'Nothing to do.' not in yum_upgrade.stdout"
|
||
when: ansible_pkg_mgr == "yum"
|