Skip to content

Commit

Permalink
Merge branch 'master-45d-octopus' into build-45d-octopus
Browse files Browse the repository at this point in the history
  • Loading branch information
bkelly16 committed Dec 12, 2021
2 parents 82af894 + 58d0986 commit 4c1eab9
Show file tree
Hide file tree
Showing 16 changed files with 294 additions and 108 deletions.
49 changes: 27 additions & 22 deletions generate-osd-vars.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,39 @@
---
- hosts: osds
tasks:
- name: execute generate-osd-vars script
command: /usr/bin/bash /opt/45drives/tools/generate-osd-vars.sh
register: output

- debug:
msg: "{{ output.stdout }}"

- local_action: file path=/usr/share/ceph-ansible/host_vars/ state=directory
when: not output.failed

- name: Check that inventory file exists
- name: Check that host inventory file exists
local_action: stat path=/usr/share/ceph-ansible/host_vars/{{ inventory_hostname }}.yml
register: stat_result
when: not output.failed

- name: Create inventory file if it does not exist
local_action: file path=/usr/share/ceph-ansible/host_vars/{{ inventory_hostname }}.yml state=touch
when: not output.failed and not stat_result.stat.exists
when: not stat_result.stat.exists

- name: execute generate-osd-vars script with dedicated devices omitted
command: /usr/bin/bash /opt/45drives/tools/generate-osd-vars.sh -d "{% for ded_dev in hostvars[inventory_hostname].dedicated_devices -%}{{ ded_dev }}{% if not loop.last %},{% endif %}{%- endfor %}"
register: osd_vars_dedicated_devices
when: (dedicated_device_db|bool) and hostvars[inventory_hostname].dedicated_devices is defined and (hostvars[inventory_hostname].dedicated_devices|length>0)

- debug:
msg: "{{ osd_vars_dedicated_devices.stdout }}"
when: osd_vars_dedicated_devices.stdout is defined

- name: execute generate-osd-vars script
command: /usr/bin/bash /opt/45drives/tools/generate-osd-vars.sh
register: osd_vars_default
when: not dedicated_device_db|bool

- debug:
msg: "{{ osd_vars_default.stdout }}"
when: osd_vars_default.stdout is defined

- name: Put generate-osd-vars default output to host inventory files
local_action: blockinfile insertbefore=BOF dest=/usr/share/ceph-ansible/host_vars/{{ inventory_hostname }}.yml block={{ osd_vars_default.stdout }} marker="# {mark} ********** generate-osd-vars.sh output **********"
when: osd_vars_default.stdout is defined and not osd_vars_default.failed

- name: Append osd-vars output to host inventory files
local_action: blockinfile insertbefore=BOF dest=/usr/share/ceph-ansible/host_vars/{{ inventory_hostname }}.yml block={{ output.stdout }} marker="# {mark} ********** generate-osd-vars.sh output **********"
when: not output.failed
- name: Put generate-osd-vars output with dedicated_devices omitted to host inventory files
local_action: blockinfile insertbefore=BOF dest=/usr/share/ceph-ansible/host_vars/{{ inventory_hostname }}.yml block={{ osd_vars_dedicated_devices.stdout }} marker="# {mark} ********** generate-osd-vars.sh output **********"
when: osd_vars_dedicated_devices.stdout is defined and not osd_vars_dedicated_devices.failed

# - name: Check for existance of host inventory files for cockpit-ceph-deploy
# local_action: stat path=/usr/share/cockpit/ceph-deploy/ceph-ansible-files/{{ inventory_hostname }}.yml
# register: stat_cockpit_ceph_deploy_inventory
# when: not output.failed
#
# - name: Add in cockpit-ceph-deploy defined variables to host inventory files
# local_action: blockinfile insertafter=EOF dest=/usr/share/ceph-ansible/host_vars/{{ inventory_hostname }}.yml block={{ lookup('file','/usr/share/cockpit/ceph-deploy/ceph-ansible-files/{{ inventory_hostname }}.yml') }} marker="# {mark} ********** cockpit-ceph-deploy make_hosts output **********"
# when: not output.failed and stat_cockpit_ceph_deploy_inventory.stat.exists
10 changes: 0 additions & 10 deletions roles/ceph-infra/tasks/configure_firewall.yml
Original file line number Diff line number Diff line change
Expand Up @@ -322,16 +322,6 @@
- rgwloadbalancer_group_name is defined
- rgwloadbalancer_group_name in group_names

- name: open http port for offline reposerver
firewalld:
port: "80/tcp"
zone: "{{ ceph_mon_firewall_zone }}"
permanent: true
immediate: true
state: enabled
when:
- offline_install | bool

- name: add rich rule for keepalived vrrp
firewalld:
rich_rule: 'rule protocol value="vrrp" accept'
Expand Down
4 changes: 3 additions & 1 deletion roles/ceph-iscsi-gw/tasks/non-container/prerequisites.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@
url: "https://download.ceph.com/ceph-iscsi/{{ '3' if use_new_ceph_iscsi | bool else '2' }}/rpm/el{{ ansible_facts['distribution_major_version'] }}/ceph-iscsi.repo"
dest: /etc/yum.repos.d/ceph-iscsi.repo
force: true
when: ceph_repository == 'community'
when:
- ceph_repository == 'community'
- not offline_install

- name: install ceph iscsi package
package:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
owner: root
group: root
backup: yes
when: not offline_install

- name: debain based systems - install required packages
block:
Expand Down
2 changes: 2 additions & 0 deletions roles/ceph-nfs/tasks/pre_requisite_non_container_red_hat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
when:
- nfs_ganesha_dev | bool
- ceph_repository == 'dev'
when: not offline_install

- name: red hat based systems - install nfs packages
block:
Expand All @@ -63,6 +64,7 @@
when:
- ansible_os_family == 'RedHat'
- ansible_distribution_major_version == '8'
- not offline_install

- name: install pacemaker
package:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
- name: ubuntu systems - repo handling
when: not offline_install
block:
- name: stable repos specific tasks
block:
Expand Down
6 changes: 5 additions & 1 deletion roles/ceph-prerun/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@

- name: setup offline repositories
include_tasks: offline/repo_setup.yml
when: offline_install
when: offline_install

- name: set grafana image fact when offline_install
set_fact: grafana_container_image="localhost/grafana-offline:5.4.2"
when: offline_install

- name: include_tasks cleanup/cleanup_on_ubuntu.yml
include_tasks: cleanup/cleanup_on_ubuntu.yml
Expand Down
20 changes: 20 additions & 0 deletions roles/ceph-prerun/tasks/offline/import_container_images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
- name: install container packages on each node
block:
- name: check if it is Atomic host
stat: path=/run/ostree-booted
register: stat_ostree
check_mode: no

- name: set_fact is_atomic
set_fact:
is_atomic: '{{ stat_ostree.stat.exists }}'
tags: always
- import_role:
name: ceph-container-engine

- name: include specific variables
include_vars: "../../../ceph-container-engine/vars/{{ ansible_facts['distribution'] }}-{{ ansible_facts['distribution_major_version'] }}.yml"

- name: import container images
include_tasks: offline/import_container_images_{{ container_service_name }}.yml
46 changes: 46 additions & 0 deletions roles/ceph-prerun/tasks/offline/import_container_images_docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
- name: Inspect node_exporter local image
docker_image_info:
name: "{{ node_exporter_container_image }}"
register: node_exporter_result

- name: Pull down and import node_exporter image if not present already
block:
- name: Pull down node_exporter image
get_url:
url: http://{{ offline_repo_server_ip }}/images/{{ node_exporter_container_image_archive }}
dest: /tmp/{{ node_exporter_container_image_archive }}

- name: Import node_exporter if not present already
shell: "/usr/bin/docker load -i /tmp/{{ node_exporter_container_image_archive }}"

- name: remove node-exporter image tar
file:
path: /tmp/{{ node_exporter_container_image_archive }}
state: absent
when: node_exporter_result.images | length == 0

- name: Inspect metrics node for local container images
docker_image_info:
name: "{{ metric_container_images }}"
register: metric_images_result

- name: Pull down and import metric stack images if not present already
block:
- name: Pull down metrics images
get_url:
url: http://{{ offline_repo_server_ip }}/images/{{ item }}
dest: /tmp/{{ item }}
loop: "{{ metric_container_images_archive|flatten(levels=1) }}"

- name: Import metric images if not present already
shell: "/usr/bin/docker load -i /tmp/{{ item }}"
loop: "{{ metric_container_images_archive|flatten(levels=1) }}"

- name: remove metric images image tar
file:
path: /tmp/{{ item }}
state: absent
loop: "{{ metric_container_images_archive|flatten(levels=1) }}"
delegate_to: "{{ groups[grafana_server_group_name][0] }}"
when: metric_images_result.images | length != 3
46 changes: 46 additions & 0 deletions roles/ceph-prerun/tasks/offline/import_container_images_podman.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
- name: Inspect node_exporter local image
podman_image_info:
name: "{{ node_exporter_container_image }}"
register: node_exporter_result

- name: Pull down and import node_exporter image if not present already
block:
- name: Pull down node_exporter image
get_url:
url: http://{{ offline_repo_server_ip }}/images/{{ node_exporter_container_image_archive }}
dest: /tmp/{{ node_exporter_container_image_archive }}

- name: Import node_exporter if not present already
shell: "/usr/bin/podman load -i /tmp/{{ node_exporter_container_image_archive }}"

- name: remove node-exporter image tar
file:
path: /tmp/{{ node_exporter_container_image_archive }}
state: absent
when: node_exporter_result.images | length == 0

- name: Inspect metrics node for local container images
podman_image_info:
name: "{{ metric_container_images }}"
register: metric_images_result

- name: Pull down and import metric stack images if not present already
block:
- name: Pull down metrics images
get_url:
url: http://{{ offline_repo_server_ip }}/images/{{ item }}
dest: /tmp/{{ item }}
loop: "{{ metric_container_images_archive|flatten(levels=1) }}"

- name: Import metric images if not present already
shell: "/usr/bin/podman load -i /tmp/{{ item }}"
loop: "{{ metric_container_images_archive|flatten(levels=1) }}"

- name: remove metric images image tar
file:
path: /tmp/{{ item }}
state: absent
loop: "{{ metric_container_images_archive|flatten(levels=1) }}"
delegate_to: "{{ groups[grafana_server_group_name][0] }}"
when: metric_images_result.images | length != 3
6 changes: 5 additions & 1 deletion roles/ceph-prerun/tasks/offline/repo_setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
## Fail if repo-server IP is not set in group_vars
- name: fail if offline_repo_server_ip fact is not set
fail:
msg: "offline_repo_server_ip varible must be set in group_vars/all.yml when using offline repos"
msg: "offline_repo_server_ip varible must be set in group_vars/all.yml when offline_install is true"
when: offline_repo_server_ip == ""

- name: setup offline repos on redhat
Expand All @@ -12,3 +12,7 @@
- name: setup offline repos on ubuntu
include_tasks: offline/repo_setup_ubuntu.yml
when: ansible_distribution == 'Ubuntu'

- name: import container images
include_tasks: offline/import_container_images.yml
when: import_container_images | bool
27 changes: 23 additions & 4 deletions roles/ceph-prerun/tasks/offline/repo_setup_redhat.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
---
- name: disable active repos
block:
- name: get active repos
shell: "dnf repolist --enabled | awk 'NR>1{print $1}'"
register: active_repos

- name: disable active repos
command: "dnf config-manager --set-disabled {{ item }}"
loop: "{{ active_repos.stdout_lines }}"

- name: place offline repo file on each node
template:
src: "Rocky-Offline.repo.j2"
dest: "/etc/yum.repos.d/Rocky-Offline.repo"
owner: root
group: root
mode: 0644

- name: install container packages on each node
- name: place GPG keys on each node
get_url:
url: http://{{ offline_repo_server_ip }}/keys/RPM-GPG-KEY-{{ item }}
dest: /etc/pki/rpm-gpg/RPM-GPG-KEY-{{ item }}
loop:
- 45drives
- ceph
- EPEL-8
- zfsonlinux

- name: import node_exporter on each node

- name: import metric container images on metrics node
64 changes: 0 additions & 64 deletions roles/ceph-prerun/tasks/offline/repo_setup_ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,67 +49,3 @@
- name: update apt cache
apt:
update_cache: yes

- name: install container packages on each node
block:
- name: check if it is Atomic host
stat: path=/run/ostree-booted
register: stat_ostree
check_mode: no

- name: set_fact is_atomic
set_fact:
is_atomic: '{{ stat_ostree.stat.exists }}'
tags: always
- import_role:
name: ceph-container-engine

- name: Inspect node_exporter local image
docker_image_info:
name:
- prom/node-exporter:v0.17.0
register: node_exporter_result

- name: Pull down and import node_exporter image if not present already
block:
- name: Pull down node_exporter image
get_url:
url: http://{{ offline_repo_server_ip }}/images/node-exporter-v0.17.0.tar
dest: /tmp/node-exporter-v0.17.0.tar

- name: Import node_exporter if not present already
shell: "/usr/bin/docker load -i /tmp/node-exporter-v0.17.0.tar"

- name: remove node-exporter image tar
file:
path: /tmp/node-exporter-v0.17.0.tar
state: absent
when: node_exporter_result.images | length == 0

- name: Inspect metrics node for local docker images
docker_image_info:
name:
- localhost/grafana-offline:5.4.2
- prom/alertmanager:v0.16.2
- prom/prometheus:v2.7.2
register: metric_images_result

- name: Pull down and import metric stack images if not present already
block:
- name: Pull down node_exporter image
get_url:
url: http://{{ offline_repo_server_ip }}/images/{{ item }}
dest: /tmp/{{ item }}
loop: "{{ metric_docker_images|flatten(levels=1) }}"

- name: Import node_exporter if not present already
shell: "/usr/bin/docker load -i /tmp/{{ item }}"
loop: "{{ metric_docker_images|flatten(levels=1) }}"

- name: remove node-exporter image tar
file:
path: /tmp/{{ item }}
state: absent
loop: "{{ metric_docker_images|flatten(levels=1) }}"
delegate_to: "{{ groups[grafana_server_group_name][0] }}"
when: metric_images_result.images | length != 3
Loading

0 comments on commit 4c1eab9

Please sign in to comment.