-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed Python install in CentOS 8 block
- Loading branch information
Showing
1 changed file
with
163 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,165 +1,164 @@ | ||
--- | ||
- hosts: all | ||
become: true | ||
vars: | ||
script_path: "{{ tmp_path }}" | ||
script_name: "wazuh-install.sh" | ||
rpm_deps: | ||
- git | ||
- python3 | ||
- python3-pip | ||
- openssl | ||
- tar | ||
apt_deps: | ||
- git | ||
- software-properties-common | ||
- gnupg2 | ||
pip_deps: | ||
- attrs==21.1.0 | ||
- importlib-metadata==4.8.2 | ||
- iniconfig==1.1.1 | ||
- packaging==21.3 | ||
- pluggy==1.0.0 | ||
- py==1.11.0 | ||
- pyparsing==3.0.6 | ||
- toml==0.10.2 | ||
- typing-extensions==4.0.0 | ||
- pytest==6.2.5 | ||
- pyyaml | ||
- requests | ||
- setuptools | ||
- beautifulsoup4 | ||
- urllib3==1.26.6 | ||
|
||
tasks: | ||
- name: Ensure Python is installed on CentOS 8 | ||
block: | ||
- name: Install Python 3 on CentOS 8 | ||
yum: | ||
name: python3 | ||
state: present | ||
when: | ||
- ansible_distribution == "CentOS" | ||
- ansible_distribution_major_version == "8" | ||
|
||
- name: Set ansible_python_interpreter for CentOS 8 | ||
set_fact: | ||
ansible_python_interpreter: /usr/bin/python3 | ||
when: | ||
- ansible_distribution == "CentOS" | ||
- ansible_distribution_major_version == "8" | ||
|
||
- name: Gather facts after Python installation | ||
ansible.builtin.setup: | ||
|
||
when: | ||
- ansible_distribution == "CentOS" | ||
- ansible_distribution_major_version == "8" | ||
|
||
- name: Make tmp folder directory | ||
file: | ||
path: "{{ tmp_path }}" | ||
state: directory | ||
|
||
- name: Install main deps block | ||
block: | ||
- name: Install required dependencies YUM | ||
ansible.builtin.package: | ||
name: "{{ rpm_deps }}" | ||
state: present | ||
when: ansible_os_family == 'RedHat' | ||
|
||
- name: Install required dependencies APT | ||
ansible.builtin.package: | ||
name: "{{ apt_deps }}" | ||
state: present | ||
update_cache: yes | ||
when: ansible_os_family == 'Debian' | ||
when: | ||
- install_deps is defined | ||
- install_deps | bool | ||
|
||
- name: Install Python and pip | ||
block: | ||
- name: Set up Python 3.9 repository | ||
apt_repository: | ||
repo: 'ppa:deadsnakes/ppa' | ||
when: | ||
- ansible_os_family == 'Debian' | ||
- ansible_distribution == "Ubuntu" | ||
|
||
- name: Install Python3.9 on Ubuntu Jammy | ||
ansible.builtin.package: | ||
name: | ||
- python3.9 | ||
- python3.9-distutils | ||
state: present | ||
update_cache: yes | ||
when: | ||
- ansible_os_family == 'Debian' | ||
- ansible_distribution == "Ubuntu" | ||
- ansible_distribution_release == "jammy" | ||
|
||
- name: Change Python link Ubuntu Jammy | ||
command: ln -sf /usr/bin/python3.9 /usr/bin/python3 | ||
when: | ||
- ansible_os_family == 'Debian' | ||
- ansible_distribution == "Ubuntu" | ||
- ansible_distribution_release == "jammy" | ||
|
||
- name: Change Python link Ubuntu Xenial | ||
command: ln -sf /usr/local/bin/python3.8 /usr/bin/python3 | ||
when: | ||
- ansible_os_family == 'Debian' | ||
- ansible_distribution == "Ubuntu" | ||
- ansible_distribution_release == "xenial" | ||
|
||
- stat: | ||
path: /usr/bin/pip3 | ||
register: stat_pip3 | ||
when: | ||
- ansible_os_family == 'Debian' | ||
|
||
- name: Install pip Ubuntu/Debian | ||
shell: curl https://bootstrap.pypa.io/get-pip.py | python3 - | ||
when: | ||
- ansible_os_family == 'Debian' | ||
- stat_pip3.stat.exists == False | ||
- ansible_distribution_release != "xenial" | ||
- ansible_distribution_release != "focal" | ||
- ansible_distribution_release != "bionic" | ||
|
||
- name: Install pip Ubuntu Xenial | ||
shell: curl https://bootstrap.pypa.io/get-pip.py | python3 - | ||
when: | ||
- ansible_os_family == 'Debian' | ||
- stat_pip3.stat.exists == False | ||
- ansible_distribution_release == "xenial" | ||
|
||
when: | ||
- install_python is defined | ||
- install_python | bool | ||
|
||
- name: Install pytest | ||
command: pip3 install {{ item }} | ||
with_items: "{{ pip_deps }}" | ||
when: | ||
- install_pip_deps is defined | ||
- install_pip_deps | bool | ||
|
||
- name: Clone installation assistant git repository | ||
git: | ||
repo: "{{ repository }}" | ||
dest: "{{ tmp_path }}" | ||
version: "{{ packages_reference }}" | ||
depth: 1 | ||
force: true | ||
|
||
- name: Generate unattended | ||
command: "bash {{ tmp_path }}/builder.sh -i -d" | ||
|
||
- name: Change pre-release repository to selected one | ||
command: "sed -i 's|pre-release|{{ pkg_repository }}|g' {{ script_name }}" | ||
args: | ||
chdir: "{{ script_path }}" | ||
|
||
- hosts: all | ||
become: true | ||
vars: | ||
script_path: "{{ tmp_path }}" | ||
script_name: "wazuh-install.sh" | ||
rpm_deps: | ||
- git | ||
- python3 | ||
- python3-pip | ||
- openssl | ||
- tar | ||
apt_deps: | ||
- git | ||
- software-properties-common | ||
- gnupg2 | ||
pip_deps: | ||
- attrs==21.1.0 | ||
- importlib-metadata==4.8.2 | ||
- iniconfig==1.1.1 | ||
- packaging==21.3 | ||
- pluggy==1.0.0 | ||
- py==1.11.0 | ||
- pyparsing==3.0.6 | ||
- toml==0.10.2 | ||
- typing-extensions==4.0.0 | ||
- pytest==6.2.5 | ||
- pyyaml | ||
- requests | ||
- setuptools | ||
- beautifulsoup4 | ||
- urllib3==1.26.6 | ||
|
||
tasks: | ||
- name: Ensure Python is installed on CentOS 8 | ||
block: | ||
- name: Install Python 3 on CentOS 8 | ||
yum: | ||
name: python3 | ||
state: present | ||
when: | ||
- ansible_distribution == "CentOS" | ||
- ansible_distribution_major_version == "8" | ||
|
||
- name: Set ansible_python_interpreter for CentOS 8 | ||
set_fact: | ||
ansible_python_interpreter: /usr/bin/python3 | ||
when: | ||
- ansible_distribution == "CentOS" | ||
- ansible_distribution_major_version == "8" | ||
|
||
- name: Gather facts after Python installation | ||
ansible.builtin.setup: | ||
|
||
when: | ||
- ansible_distribution == "CentOS" | ||
- ansible_distribution_major_version == "8" | ||
|
||
- name: Make tmp folder directory | ||
file: | ||
path: "{{ tmp_path }}" | ||
state: directory | ||
|
||
- name: Install main deps block | ||
block: | ||
- name: Install required dependencies YUM | ||
ansible.builtin.package: | ||
name: "{{ rpm_deps }}" | ||
state: present | ||
when: ansible_os_family == 'RedHat' | ||
|
||
- name: Install required dependencies APT | ||
ansible.builtin.package: | ||
name: "{{ apt_deps }}" | ||
state: present | ||
update_cache: yes | ||
when: ansible_os_family == 'Debian' | ||
when: | ||
- install_deps is defined | ||
- install_deps | bool | ||
|
||
- name: Install Python and pip | ||
block: | ||
- name: Set up Python 3.9 repository | ||
apt_repository: | ||
repo: 'ppa:deadsnakes/ppa' | ||
when: | ||
- ansible_os_family == 'Debian' | ||
- ansible_distribution == "Ubuntu" | ||
|
||
- name: Install Python3.9 on Ubuntu Jammy | ||
ansible.builtin.package: | ||
name: | ||
- python3.9 | ||
- python3.9-distutils | ||
state: present | ||
update_cache: yes | ||
when: | ||
- ansible_os_family == 'Debian' | ||
- ansible_distribution == "Ubuntu" | ||
- ansible_distribution_release == "jammy" | ||
|
||
- name: Change Python link Ubuntu Jammy | ||
command: ln -sf /usr/bin/python3.9 /usr/bin/python3 | ||
when: | ||
- ansible_os_family == 'Debian' | ||
- ansible_distribution == "Ubuntu" | ||
- ansible_distribution_release == "jammy" | ||
|
||
- name: Change Python link Ubuntu Xenial | ||
command: ln -sf /usr/local/bin/python3.8 /usr/bin/python3 | ||
when: | ||
- ansible_os_family == 'Debian' | ||
- ansible_distribution == "Ubuntu" | ||
- ansible_distribution_release == "xenial" | ||
|
||
- stat: | ||
path: /usr/bin/pip3 | ||
register: stat_pip3 | ||
when: | ||
- ansible_os_family == 'Debian' | ||
|
||
- name: Install pip Ubuntu/Debian | ||
shell: curl https://bootstrap.pypa.io/get-pip.py | python3 - | ||
when: | ||
- ansible_os_family == 'Debian' | ||
- stat_pip3.stat.exists == False | ||
- ansible_distribution_release != "xenial" | ||
- ansible_distribution_release != "focal" | ||
- ansible_distribution_release != "bionic" | ||
|
||
- name: Install pip Ubuntu Xenial | ||
shell: curl https://bootstrap.pypa.io/get-pip.py | python3 - | ||
when: | ||
- ansible_os_family == 'Debian' | ||
- stat_pip3.stat.exists == False | ||
- ansible_distribution_release == "xenial" | ||
|
||
when: | ||
- install_python is defined | ||
- install_python | bool | ||
|
||
- name: Install pytest | ||
command: pip3 install {{ item }} | ||
with_items: "{{ pip_deps }}" | ||
when: | ||
- install_pip_deps is defined | ||
- install_pip_deps | bool | ||
|
||
- name: Clone installation assistant git repository | ||
git: | ||
repo: "{{ repository }}" | ||
dest: "{{ tmp_path }}" | ||
version: "{{ packages_reference }}" | ||
depth: 1 | ||
force: true | ||
|
||
- name: Generate unattended | ||
command: "bash {{ tmp_path }}/builder.sh -i -d" | ||
|
||
- name: Change pre-release repository to selected one | ||
command: "sed -i 's|pre-release|{{ pkg_repository }}|g' {{ script_name }}" | ||
args: | ||
chdir: "{{ script_path }}" |