browbeat/ansible/install/roles/browbeat/tasks/main.yml

187 lines
5.4 KiB
YAML

---
#
# Browbeat Install
#
- name: Check for supported distribution
fail: msg="**Unsupported Linux distribution! Please use CentOS 7+, RHEL 7+, or add support for your distribution**"
when: not supported_distro
- name: Install dependencies for CentOS
yum:
name:
- gcc
- gcc-c++
- git
- libffi-devel
- libsemanage-python
- openssl-devel
- policycoreutils-python
- python-devel
- python3
state: present
become: true
when: ansible_distribution_major_version < '8'
ignore_errors: yes
- name: Install dependencies for RHEL8 and RHEL9
yum:
name:
- gcc
- gcc-c++
- git
- libffi-devel
- python3-libsemanage
- openssl-devel
- python3-policycoreutils
- python3-devel
- python3-pip
state: present
become: true
when: ansible_distribution_major_version >= '8'
- name: Install dependency virtualenv for RHEL8
yum:
name:
- python3-virtualenv
state: present
become: true
when: ansible_distribution_major_version == '8'
- name: Install pip
block:
- name: get the pip installer
get_url:
validate_certs: no
url: "https://bootstrap.pypa.io/pip/2.7/get-pip.py"
dest: "/tmp/get-pip.py"
force: yes
- name: run pip installer
shell: python /tmp/get-pip.py
when: ansible_distribution_major_version < '8'
- name: Update virtualenv and setuptools
pip:
name: "{{item.name}}"
state: latest
become: true
with_items:
- name: virtualenv
- name: setuptools
ignore_errors: True
when: ansible_user != "zuul" and ansible_distribution_major_version < '8'
- name: Install virtualenv and setuptools- zuul user
pip:
name:
- virtualenv
- setuptools
become: true
when: ansible_user == "zuul" and ansible_distribution_major_version < '8'
- name: Determine if browbeat directory exists already
stat:
path: "{{ browbeat_path }}"
register: browbeat_exists
- debug: msg="Browbeat directory exists already."
when: browbeat_exists.stat.isdir is defined and browbeat_exists.stat.isdir
- name: install scapy
pip:
name: "scapy"
state: latest
become: true
when: ansible_distribution_major_version >= '8'
- name: Clone browbeat on undercloud
git:
repo: https://github.com/openstack/browbeat.git
dest: "{{ browbeat_path }}"
version: master
when: browbeat_exists.stat.isdir is undefined
- name: Create browbeat virtualenv
command: virtualenv {{ browbeat_venv }} creates={{ browbeat_venv }}
when: ansible_distribution_major_version <= '8'
- name: Create browbeat virtualenv
command: python3 -m venv {{ browbeat_venv }} creates={{ browbeat_venv }}
when: ansible_distribution_major_version == '9'
- name: Setup browbeat-venv CA certificate path
lineinfile:
dest: "{{ browbeat_venv }}/bin/activate"
line: 'export REQUESTS_CA_BUNDLE={{ overcloud_ca_path }}'
when: overcloud_ca_path is defined
- block:
- name: Determine if generate_tripleo_hostfile has been run
stat:
path: "{{ browbeat_path }}/ansible/hosts"
register: hosts_file_exists
- name: Determine if generate_tripleo_inventory has been run
stat:
path: "{{ browbeat_path }}/ansible/hosts.yml"
register: hosts_yml_file_exists
- name: set either of inventory file exists
set_fact:
inventry_file: "{{ (hosts_file_exists.stat.exists and hosts_file_exists.stat.isreg) or (hosts_yml_file_exists.stat.exists and hosts_yml_file_exists.stat.isreg) }}"
- debug:
msg: "Hosts file is already generated. {{ inventry_file }}"
when: inventry_file
- name: Generate hosts and ssh-config on Browbeat Machine - Default(stack)
shell: . {{ home_dir }}/stackrc; {{ browbeat_path }}/ansible/generate_tripleo_inventory.sh -l --user stack
when: tripleo and (not inventry_file) and ansible_user != "zuul"
- name: Generate hosts and ssh-config on Browbeat Machine - Zuul
shell: . {{ home_dir }}/stackrc; {{ browbeat_path }}/ansible/generate_tripleo_inventory.sh -l --user zuul
when: tripleo and (not inventry_file) and ansible_user == "zuul"
- name: Move files to correct location
command: mv {{ item }} {{ browbeat_path }}/ansible/{{ item }}
with_items:
- hosts.yml
- heat-admin-id_rsa
when: tripleo and (not inventry_file)
when: not is_rhoso_deployment
- name: Install requirements.txt into browbeat-venv
pip:
requirements: "{{ browbeat_path }}/requirements.txt"
virtualenv: "{{ browbeat_venv }}"
- block:
- name: Uninstall old grafyaml version
pip:
name: grafyaml==0.0.7
virtualenv: "{{ browbeat_venv }}"
state: absent
- name: Install grafyaml version 0.0.8 for Prometheus-Grafana
pip:
name: git+https://opendev.org/opendev/grafyaml.git
virtualenv: "{{ browbeat_venv }}"
- name: Get the python version installed
command: echo "{{ ansible_python_version }}"
register: installed_python_version
- name: Set fact for installed python version
set_fact:
installed_python_version: "{{installed_python_version.stdout[0:3]}}"
- name: Add regex option in grafyaml
lineinfile:
path: "{{ browbeat_path }}/.browbeat-venv/lib/python{{installed_python_version}}/site-packages/grafana_dashboards/schema/template/query.py"
insertafter: "hide"
line: " v.Optional('regex',default=''): v.All(str),"
when: collectd_prometheus and not is_rhoso_deployment