Files
offline_kubespray/collection/community/zabbix/molecule/zabbix_proxy/prepare.yml
ByeonJungHun 360c6eef4a offline 작업
2024-02-19 16:02:29 +09:00

130 lines
3.2 KiB
YAML

---
- name: Prepare
hosts: localhost
connection: local
pre_tasks:
- name: "Create MySQL Container"
docker_container:
name: mysql-host
image: mysql:8.0
state: started
recreate: true
networks:
- name: zabbix
env:
MYSQL_ROOT_PASSWORD: changeme
no_log: true
with_items: "{{ molecule_yml.platforms }}"
when:
- '"mysql" in item.groups'
- name: "Create postgresql Container"
docker_container:
name: postgresql-host
image: postgres:13
state: started
recreate: true
networks:
- name: zabbix
env:
POSTGRES_PASSWORD: changeme
no_log: true
with_items: "{{ molecule_yml.platforms }}"
when:
- '"postgresql" in item.groups'
- name: Prepare
hosts: all
tasks:
- name: "Set short version name"
set_fact:
zabbix_python_prefix: "python{% if ansible_python_version is version('3', '>=') %}3{% endif %}"
- name: "Create group for imaginary host"
add_host:
name: imaginary-host
groups:
- mysql
- postgresql
changed_when: false
- name: "Installing packages on CentOS"
yum:
name:
- net-tools
- which
- sudo
state: present
register: installation_dependencies
until: installation_dependencies is succeeded
when:
- ansible_os_family == 'RedHat'
- name: "Installing packages on CentOS"
yum:
name:
- mysql
state: present
register: installation_dependencies
until: installation_dependencies is succeeded
when:
- ansible_os_family == 'RedHat'
- inventory_hostname in groups['mysql']
- name: "Apt update"
shell: "apt-get update && echo exit 0 > /usr/sbin/policy-rc.d"
args:
warn: false
register: installation_dependencies
until: installation_dependencies is succeeded
when:
- ansible_os_family != 'RedHat'
- name: "Installing packages on NON-CentOS"
apt:
name:
- net-tools
- apt-utils
- "{{ zabbix_python_prefix }}-pip"
- gpg-agent
- sudo
- doc-base
update_cache: true
state: present
register: installation_dependencies
until: installation_dependencies is succeeded
when:
- ansible_os_family != 'RedHat'
- name: "Configure SUDO."
lineinfile:
dest: /etc/sudoers
line: "Defaults !requiretty"
state: present
- name: "Make sure the docs can be installed. (RedHat)"
lineinfile:
dest: /etc/yum.conf
line: "tsflags=nodocs"
state: absent
when:
- ansible_os_family == 'RedHat'
- name: "Make sure the docs can be installed. (Debian)"
lineinfile:
path: /etc/dpkg/dpkg.cfg.d/excludes
state: absent
regexp: 'path-exclude=/usr/share/doc/*'
when:
- ansible_os_family != 'RedHat'
- name: PyMySQL
pip:
name: PyMySQL
register: installation_dependencies
until: installation_dependencies is succeeded
when:
- inventory_hostname in groups['mysql']