
Ceph SocketPath has changed in OSP17. Now the path includes fsid also. Change-Id: I2afb25cf2ef971b668c9c92f9552f35863ee0eb3
300 lines
11 KiB
YAML
300 lines
11 KiB
YAML
---
|
|
- name: Fetch log file paths
|
|
include_vars:
|
|
file: "vars/{{ rhosp_major }}.yml"
|
|
|
|
- name: (Undercloud) Get ctlplane ip address
|
|
shell: ip r | egrep 'br-ctlplane\s*proto kernel' | awk '{print $NF}'
|
|
register: undercloud_ctlplane_ip_address
|
|
when: "'Undercloud' in group_names"
|
|
|
|
- name: Configure mysql for collectd.conf
|
|
block:
|
|
- name: (Controller) Get mysql root password
|
|
command: hiera -c /etc/puppet/hiera.yaml mysql::server::root_password
|
|
become: true
|
|
register: mysql_root_password
|
|
when: "'Controller' in group_names"
|
|
|
|
- name: (Undercloud) Get mysql root password
|
|
become: true
|
|
shell: |
|
|
grep 'mysql::server::root_password' /etc/puppet/hieradata/service_configs.json | awk -F'"' '{print $4}'
|
|
register: undercloud_mysql_password
|
|
when: "'Undercloud' in group_names"
|
|
|
|
- name: Configure rabbitmq monitoring
|
|
block:
|
|
- name: (Undercloud) Get Rabbitmq username
|
|
command: hiera -c /etc/puppet/hiera.yaml rabbitmq::default_user
|
|
become: true
|
|
register: undercloud_rabbitmq_username
|
|
when: "('Undercloud' in group_names and rabbitmq_undercloud_collectd_plugin)"
|
|
|
|
- name: (Undercloud) Get Rabbitmq password
|
|
command: hiera -c /etc/puppet/hiera.yaml rabbitmq::default_pass
|
|
become: true
|
|
register: undercloud_rabbitmq_password
|
|
when: "('Undercloud' in group_names and rabbitmq_undercloud_collectd_plugin)"
|
|
|
|
- name: (Controller) Get Rabbitmq username
|
|
command: hiera -c /etc/puppet/hiera.yaml rabbitmq::default_user
|
|
register: controller0_rabbitmq_username
|
|
become: true
|
|
when: "'Controller' in group_names and rabbitmq_controller_collectd_plugin and inventory_hostname == groups['Controller'][0]"
|
|
|
|
- name: (Controller) Get Rabbitmq password
|
|
command: hiera -c /etc/puppet/hiera.yaml rabbitmq::default_pass
|
|
register: controller0_rabbitmq_password
|
|
become: true
|
|
when: "'Controller' in group_names and rabbitmq_controller_collectd_plugin and inventory_hostname == groups['Controller'][0]"
|
|
|
|
- name: Check if Container Files Directory exists
|
|
stat:
|
|
path: "{{ ansible_user_dir }}/browbeat/browbeat-containers/collectd-openstack"
|
|
register: directory_exists
|
|
|
|
- name: Clone browbeat if it doesn't exists on host
|
|
git:
|
|
repo: https://github.com/openstack/browbeat.git
|
|
dest: "{{ ansible_user_dir }}/browbeat"
|
|
version: master
|
|
when: not (directory_exists.stat.isdir is defined and directory_exists.stat.isdir)
|
|
|
|
- name: install sqlalchemy collectd package inside the containers
|
|
block:
|
|
- name: packages needed for installing sqlalchemy collectd
|
|
vars:
|
|
rhos_release: http://download-node-02.eng.bos.redhat.com/rcm-guest/puddles/OpenStack/rhos-release/rhos-release-latest.noarch.rpm
|
|
set_fact:
|
|
packages_sqlalchemy_collectd: dnf install -y {{ rhos_release }} && rhos-release {{ rhosp_major }} && dnf install -y python3-sqlalchemy-collectd
|
|
|
|
- name: install python3-sqlalchemy-collectd
|
|
become: true
|
|
shell: |
|
|
podman exec -it -u root {{ item }} /bin/bash -c "{{ packages_sqlalchemy_collectd }}"
|
|
with_items:
|
|
- cinder_api
|
|
- cinder_api_cron
|
|
- cinder_scheduler
|
|
- nova_conductor
|
|
- nova_api_cron
|
|
- nova_scheduler
|
|
- nova_vnc_proxy
|
|
- nova_api
|
|
- nova_metadata
|
|
- neutron_api
|
|
- keystone
|
|
- heat_api
|
|
- heat_engine
|
|
- heat_api_cron
|
|
- heat_api_cfn
|
|
when: (rhosp_version is version('16.2', '>=') and 'Controller' in group_names and sqlalchemy_collectd_plugin)
|
|
|
|
- name: Get mysql string
|
|
shell: "crudini --get {{item.value.path}} database connection"
|
|
become: true
|
|
register: db_connections
|
|
with_dict: "{{mysql_svcs}}"
|
|
when: ('Controller' in group_names and sqlalchemy_collectd_plugin)
|
|
ignore_errors: true
|
|
|
|
- name: Append to mysql string
|
|
ini_file:
|
|
backup: true
|
|
dest: "{{ item.item.value.path }}"
|
|
section: database
|
|
option: connection
|
|
value: "{{ item.stdout }}&plugin=collectd&collectd_program_name={{ item.item.key }}"
|
|
when: (('Controller' in group_names) and sqlalchemy_collectd_plugin and ('plugin=collectd' not in item.stdout))
|
|
with_items: "{{ db_connections.results }}"
|
|
become: true
|
|
|
|
- name: restart containers
|
|
shell: podman restart {{ item }}
|
|
become: true
|
|
with_items:
|
|
- cinder_api
|
|
- cinder_api_cron
|
|
- cinder_scheduler
|
|
- nova_conductor
|
|
- nova_api_cron
|
|
- nova_scheduler
|
|
- nova_vnc_proxy
|
|
- nova_api
|
|
- nova_metadata
|
|
- neutron_api
|
|
- keystone
|
|
- heat_api
|
|
- heat_engine
|
|
- heat_api_cron
|
|
- heat_api_cfn
|
|
ignore_errors: yes
|
|
when: ('Controller' in group_names and sqlalchemy_collectd_plugin)
|
|
|
|
# Apache Monitoring
|
|
- name: Deploy Apache mod_status conf
|
|
template:
|
|
src: 00-browbeat_mod_status.conf.j2
|
|
dest: /etc/httpd/conf.d/00-browbeat_mod_status.conf
|
|
owner: root
|
|
group: root
|
|
become: true
|
|
when: "('Undercloud' in group_names and apache_undercloud_collectd_plugin)"
|
|
|
|
- name: (Undercloud) Allow httpd to listen to port ({{apache_undercloud_mod_status_port}})
|
|
command: "/usr/sbin/semanage port -m -t http_port_t -p tcp {{apache_undercloud_mod_status_port}}"
|
|
become: true
|
|
when: "('Undercloud' in group_names and apache_undercloud_collectd_plugin)"
|
|
|
|
- name: Restart Apache
|
|
service:
|
|
name: httpd
|
|
state: restarted
|
|
enabled: true
|
|
become: true
|
|
when: "('Undercloud' in group_names and apache_undercloud_collectd_plugin)"
|
|
# End Apache Monitoring
|
|
|
|
# CephStorage OSD monitoring
|
|
# Only Monitors a single OSD on each CephStorage Node
|
|
- name: Get 1st OSD socket
|
|
shell: ls /var/run/ceph/ceph-osd.*.asok | head -n 1 | egrep -o '[0-9]+'
|
|
register: cephstorage_osd_socket
|
|
become: true
|
|
when: "('CephStorage' in group_names and ceph_storage_collectd_plugin) and (rhosp_version is version('17.0', '<'))"
|
|
# End CephStorage OSD monitoring
|
|
|
|
- name: Get Ceph cluster fsid
|
|
shell: ls /var/run/ceph/
|
|
register: ceph_cluster_fsid
|
|
become: true
|
|
when: "rhosp_version is version('17.0', '>=')"
|
|
delegate_to: controller-0
|
|
|
|
- name: set fact for ceph cluster id
|
|
set_fact:
|
|
ceph_cluster_fsid: "{{ ceph_cluster_fsid.stdout }}"
|
|
|
|
- name: Get 1st OSD socket
|
|
shell: cephadm shell -- ls /var/run/ceph/ | head -n 1 | egrep -o '[0-9]+'
|
|
register: cephstorage_osd_socket
|
|
become: true
|
|
when: "('CephStorage' in group_names and ceph_storage_collectd_plugin) and (rhosp_version is version('17.0', '>='))"
|
|
|
|
- name: Create configuration directory
|
|
file:
|
|
path: "{{ browbeat_containers_path }}/collectd-openstack/config"
|
|
state: directory
|
|
|
|
- name: Configure collectd.conf
|
|
template:
|
|
src: "{{ config_type }}.collectd.conf.j2"
|
|
dest: "{{ browbeat_containers_path }}/collectd-openstack/config/collectd.conf"
|
|
when: "config_type != 'compute'"
|
|
|
|
- name: Configure compute collectd.conf
|
|
template:
|
|
src: "{{ config_type }}.collectd.conf.j2"
|
|
dest: "{{ browbeat_containers_path }}/collectd-openstack/config/collectd.conf"
|
|
when: "config_type == 'compute' and not ovn_compute_collectd_plugin"
|
|
|
|
- name: Configure compute collectd.conf
|
|
template:
|
|
src: "ovn_compute.collectd.conf.j2"
|
|
dest: "{{ browbeat_containers_path }}/collectd-openstack/config/collectd.conf"
|
|
when: "config_type == 'compute' and ovn_compute_collectd_plugin"
|
|
|
|
- name: Create pipe for to use pcs cli inside collectd container
|
|
shell: |
|
|
sudo mkfifo /home/"{{ host_remote_user }}"/collectd_pipe
|
|
become: yes
|
|
become_user: root
|
|
ignore_errors: yes
|
|
when: "config_type == 'controller' and pacemaker_monitoring"
|
|
|
|
- name: Create script to run eval on pcs pipe
|
|
file:
|
|
path: "/home/{{ host_remote_user }}/collectd_pipe_eval.sh"
|
|
state: touch
|
|
mode: 0775
|
|
owner: root
|
|
become: yes
|
|
become_user: root
|
|
ignore_errors: yes
|
|
when: "config_type == 'controller' and pacemaker_monitoring"
|
|
|
|
- name: Add content to script to run eval on pcs pipe
|
|
copy:
|
|
dest: "/home/{{ host_remote_user }}/collectd_pipe_eval.sh"
|
|
content: |
|
|
while true; do eval "$(cat /home/{{ host_remote_user }}/collectd_pipe)"; done
|
|
become: yes
|
|
become_user: root
|
|
ignore_errors: yes
|
|
when: "config_type == 'controller' and pacemaker_monitoring"
|
|
|
|
- name: Run script to run eval on pcs pipe
|
|
shell: |
|
|
nohup ./collectd_pipe_eval.sh > /var/log/containers/stdouts/collectd_pacemaker.out 2>&1 &
|
|
become: yes
|
|
become_user: root
|
|
ignore_errors: yes
|
|
args:
|
|
chdir: "/home/{{ host_remote_user }}"
|
|
when: "config_type == 'controller' and pacemaker_monitoring"
|
|
|
|
- name: Build and Run container
|
|
block:
|
|
- name: Build collectd-openstack container
|
|
shell: |
|
|
{{ container_cli }} build -t collectd-openstack {{ browbeat_containers_path }}/collectd-openstack/
|
|
become: true
|
|
- name: Run collectd-openstack container
|
|
shell: |
|
|
{{ container_cli }} rm -f collectd-{{ config_type }}
|
|
{{ container_cli }} run --name collectd-{{ config_type }} \
|
|
--network host --pid host \
|
|
--privileged -d \
|
|
-v /var/log/containers:/var/log/containers \
|
|
-v /dev:/dev \
|
|
{% if config_type == 'controller' or config_type == 'undercloud' %}
|
|
-v /var/lib/mysql/mysql.sock:/var/lib/mysql/mysql.sock \
|
|
{% endif %}
|
|
{% if config_type == 'controller' or config_type == 'compute' %}
|
|
{% if ovs_flows_monitoring %}
|
|
-v /etc/openvswitch/:/etc/openvswitch/ -v /var/run/openvswitch/:/var/run/openvswitch/ \
|
|
{% endif %}
|
|
{% endif %}
|
|
{% if config_type == 'controller' %}
|
|
{% if ovn_monitoring %}
|
|
-v /var/lib/openvswitch/ovn/ovnnb_db.sock:/var/lib/openvswitch/ovn/ovnnb_db.sock \
|
|
-v /var/lib/openvswitch/ovn/ovnsb_db.sock:/var/lib/openvswitch/ovn/ovnsb_db.sock \
|
|
{% endif %}
|
|
{% if ovn_raft_monitoring %}
|
|
-v /var/lib/openvswitch/ovn/ovnnb_db.ctl:/var/lib/openvswitch/ovn/ovnnb_db.ctl \
|
|
-v /var/lib/openvswitch/ovn/ovnsb_db.ctl:/var/lib/openvswitch/ovn/ovnsb_db.ctl \
|
|
{% endif %}
|
|
{% if pacemaker_monitoring %}
|
|
-v /home/{{ host_remote_user }}/collectd_pipe:/collectd_pipe \
|
|
{% endif %}
|
|
{% endif %}
|
|
{% if config_type == 'controller' and ceph_controller_collectd_plugin and inventory_hostname == groups['Controller'][0] %}
|
|
-v /etc/ceph/:/etc/ceph/ -v /var/run/ceph/:/var/run/ceph \
|
|
{% endif %}
|
|
{% if config_type == 'compute' and virt_collectd_plugin %}
|
|
-v /var/run/libvirt/libvirt-sock-ro:/var/run/libvirt/libvirt-sock-ro \
|
|
{% endif %}
|
|
{% if config_type == 'cephstorage' and ceph_storage_collectd_plugin and inventory_hostname == groups['CephStorage'][0] %}
|
|
-v /var/run/ceph/:/var/run/ceph \
|
|
{% endif %}
|
|
collectd-openstack
|
|
become: yes
|
|
|
|
- name: Add stack user to wheel
|
|
shell: |
|
|
podman exec -it -u root collectd-controller usermod -G wheel stack
|
|
become: yes
|
|
become_user: root
|
|
when: "config_type == 'controller' and (ovn_monitoring or ovn_raft_monitoring)"
|