187 lines
7.0 KiB
YAML
187 lines
7.0 KiB
YAML
---
|
|
- block:
|
|
- name: Fetch Cluster IP and Ports for openstack service
|
|
command: oc get svc openstack -n openstack -o jsonpath='{.spec.clusterIP} {.spec.ports[0].port}'
|
|
register: openstack_svc
|
|
|
|
- name: Fetch Cluster IP and Ports for openstack cell1 service
|
|
command: oc get svc openstack-cell1 -n openstack -o jsonpath='{.spec.clusterIP} {.spec.ports[0].port}'
|
|
register: openstack_cell1_svc
|
|
|
|
- name: Fetch Cluster IP and Ports for ovsdbserver-nb-0 service
|
|
command: oc get svc ovsdbserver-nb-0 -n openstack -o jsonpath='{.spec.clusterIP} {.spec.ports[0].port}'
|
|
register: ovsdbserver_nb_0_svc
|
|
|
|
- name: Fetch Cluster IP and Ports for ovsdbserver-sb-0 service
|
|
command: oc get svc ovsdbserver-sb-0 -n openstack -o jsonpath='{.spec.clusterIP} {.spec.ports[0].port}'
|
|
register: ovsdbserver_sb_0_svc
|
|
|
|
- name: Retrieve the DbRootPassword from the secret
|
|
command: oc get secret osp-secret -n openstack -o jsonpath='{.data.DbRootPassword}'
|
|
register: DbRootPassword_output
|
|
|
|
- name: Retrive DB config node hostname
|
|
shell: |
|
|
oc debug node/$(oc get nodes -l node-role.kubernetes.io/worker --no-headers | awk 'NR==1 {print $1}') -- hostname -f 2>/dev/null | tr '.' '_'
|
|
register: db_config_node_hostname
|
|
|
|
- name: Fetch all the worker node names
|
|
command: oc get nodes -o jsonpath='{range .items[?(@.metadata.labels.node-role\.kubernetes\.io/worker)]}{.metadata.name}{"\n"}{end}'
|
|
register: worker_nodes
|
|
|
|
- name: Fetch Cluster IP and Ports for rabbitmq service
|
|
shell: |
|
|
oc get svc rabbitmq -n openstack -o jsonpath='{.spec.clusterIP} {.spec.ports[1].port}'
|
|
register: rabbitmq_svc
|
|
|
|
- name: Fetch rabbitmq default username and password
|
|
shell: |
|
|
oc get secret rabbitmq-default-user -n openstack -o jsonpath='{.data.default_user\.conf}' | base64 --decode
|
|
register: rabbitmq_default_user_conf
|
|
environment:
|
|
KUBECONFIG: "{{ kubeconfig_path }}"
|
|
|
|
- name: Parse openstack service details
|
|
set_fact:
|
|
openstack_svc_ip: "{{ openstack_svc.stdout.split(' ')[0] }}"
|
|
openstack_svc_port: "{{ openstack_svc.stdout.split(' ')[1] }}"
|
|
|
|
- name: Parse openstack service cell1 details
|
|
set_fact:
|
|
openstack_cell1_svc_ip: "{{ openstack_cell1_svc.stdout.split(' ')[0] }}"
|
|
openstack_cell1_svc_port: "{{ openstack_cell1_svc.stdout.split(' ')[1] }}"
|
|
|
|
- name: Parse ovsdbserver-nb-0 service details
|
|
set_fact:
|
|
ovsdbserver_nb_0_svc_ip: "{{ ovsdbserver_nb_0_svc.stdout.split(' ')[0] }}"
|
|
ovsdbserver_nb_0_svc_port: "{{ ovsdbserver_nb_0_svc.stdout.split(' ')[1] }}"
|
|
|
|
- name: Parse ovsdbserver-sb-0 service details
|
|
set_fact:
|
|
ovsdbserver_sb_0_svc_ip: "{{ ovsdbserver_sb_0_svc.stdout.split(' ')[0] }}"
|
|
ovsdbserver_sb_0_svc_port: "{{ ovsdbserver_sb_0_svc.stdout.split(' ')[1] }}"
|
|
|
|
- name: Parse rabbitmq service details
|
|
set_fact:
|
|
rabbitmq_svc_ip: "{{ rabbitmq_svc.stdout.split(' ')[0] }}"
|
|
rabbitmq_svc_port: "{{ rabbitmq_svc.stdout.split(' ')[1] }}"
|
|
|
|
- name: Parse rabbitmq username and password
|
|
set_fact:
|
|
rabbitmq_username: "{{ rabbitmq_default_user_conf.stdout | regex_findall('default_user = (\\S+)') | first }}"
|
|
rabbitmq_password: "{{ rabbitmq_default_user_conf.stdout | regex_findall('default_pass = (\\S+)') | first }}"
|
|
|
|
- name: generate logfiles vars for each worker nodes
|
|
include_tasks: gen_logfile_vars.yml
|
|
loop: "{{ worker_nodes.stdout_lines }}"
|
|
loop_control:
|
|
loop_var: node
|
|
|
|
- name: Decode the Base64 encoded DbRootPassword
|
|
set_fact:
|
|
mysql_root_password: "{{ DbRootPassword_output.stdout | b64decode }}"
|
|
|
|
- name: set fact for mysql host ip and port
|
|
set_fact:
|
|
mysql_host_ip: "{{ openstack_svc_ip }}"
|
|
mysql_port: "{{ openstack_svc_port }}"
|
|
|
|
- name: set fact for mysql cell1 host ip and port
|
|
set_fact:
|
|
mysql_cell1_host_ip: "{{ openstack_cell1_svc_ip }}"
|
|
mysql_cell1_port: "{{ openstack_cell1_svc_port }}"
|
|
|
|
- name: Create environment file with key-value pairs
|
|
copy:
|
|
dest: /tmp/env_file.env
|
|
content: |
|
|
COLLECTD_INTERVAL={{ collectd_interval }}
|
|
OVN_NBDB_IP={{ ovsdbserver_nb_0_svc_ip }}
|
|
OVN_NBDB_PORT={{ ovsdbserver_nb_0_svc_port }}
|
|
OVN_SBDB_IP={{ ovsdbserver_sb_0_svc_ip }}
|
|
OVN_SBDB_PORT={{ ovsdbserver_sb_0_svc_port }}
|
|
|
|
- name: generate templates
|
|
include_tasks: gen_configs.yml
|
|
loop: "{{ worker_nodes.stdout_lines }}"
|
|
loop_control:
|
|
loop_var: node
|
|
index_var: idx
|
|
|
|
- name: delete existing ospperf namespace
|
|
shell: |
|
|
oc delete project ospperf --force
|
|
ignore_errors: yes
|
|
|
|
- name: Create ospperf namespace
|
|
shell:
|
|
cmd: oc new-project ospperf
|
|
register: create_ns
|
|
environment:
|
|
KUBECONFIG: "{{ kubeconfig_path }}"
|
|
|
|
- name: collect all config file paths
|
|
set_fact:
|
|
config_files: "{{ worker_nodes.stdout_lines | map('regex_replace', '^', '/tmp/') | map('regex_replace', '$', '.conf') }}"
|
|
|
|
- block:
|
|
- name: Copy cert secrets from openstack ns to ospperf
|
|
shell: |
|
|
oc get secret {{ item }} -n openstack -o yaml | sed 's/namespace: openstack/namespace: ospperf/' | oc apply -n ospperf -f -
|
|
loop:
|
|
- cert-ovndbcluster-sb-ovndbs
|
|
- cert-ovndbcluster-nb-ovndbs
|
|
- cert-rabbitmq-svc
|
|
|
|
- name: Create configmaps for collectd configs
|
|
shell: |
|
|
oc create -n ospperf configmap collectd-configs --from-file={{ config_files | join(' --from-file=') }}
|
|
|
|
- name: Create collectd entrypoint configmap
|
|
shell: |
|
|
oc create configmap collectd-entrypoint --from-file="{{ role_path }}/files/entrypoint.sh" -n ospperf
|
|
|
|
- name: Create collectd env configmap
|
|
shell: |
|
|
oc create configmap collectd-env-vars --from-env-file=/tmp/env_file.env -n ospperf
|
|
|
|
- name: Apply collectd deployment yaml
|
|
shell: |
|
|
oc apply -f {{ role_path }}/files/collectd_deploy.yaml -n ospperf
|
|
|
|
- name: Wait for all pods to be in Running state
|
|
shell: |
|
|
expected_count={{ worker_nodes.stdout_lines|length }}
|
|
running_count=$(oc get pods -n ospperf -o jsonpath='{.items[?(@.status.phase=="Running")].metadata.name}' | wc -w)
|
|
[ "$running_count" -eq "$expected_count" ] && echo "running" || echo "failure"
|
|
register: pod_status
|
|
retries: 10
|
|
delay: 30
|
|
until: pod_status.stdout == "running"
|
|
|
|
- name: Create prometheus cluster role and rolebinding
|
|
shell: |
|
|
oc apply -f "{{ role_path }}/files/prometheus_cluster_role.yaml"
|
|
oc apply -f "{{ role_path }}/files/prometheus_cluster_rolebinding.yaml"
|
|
|
|
- name: Render service yamls for each collectd pod
|
|
template:
|
|
src: collectd_svc_template.yaml.j2
|
|
dest: /tmp/collectd_svc_{{ item }}.yaml
|
|
loop: "{{ range(0, worker_nodes.stdout_lines|length) }}"
|
|
vars:
|
|
idx: "{{ item }}"
|
|
|
|
- name: Apply generated service yamls
|
|
shell: |
|
|
oc apply -f /tmp/collectd_svc_{{ item }}.yaml
|
|
loop: "{{ range(0, worker_nodes.stdout_lines|length) }}"
|
|
when: worker_nodes.stdout_lines is defined
|
|
|
|
- name: Apply prometheus service monitor
|
|
shell: |
|
|
oc apply -f "{{ role_path }}/files/collectd_svc_monitor.yaml"
|
|
when: create_ns.rc == 0
|
|
environment:
|
|
KUBECONFIG: "{{ kubeconfig_path }}"
|