diff --git a/generate-osd-vars.yml b/generate-osd-vars.yml index 77255f5613..b223b28e74 100644 --- a/generate-osd-vars.yml +++ b/generate-osd-vars.yml @@ -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 diff --git a/roles/ceph-infra/tasks/configure_firewall.yml b/roles/ceph-infra/tasks/configure_firewall.yml index 5f45bfd6d8..c7972518dc 100644 --- a/roles/ceph-infra/tasks/configure_firewall.yml +++ b/roles/ceph-infra/tasks/configure_firewall.yml @@ -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' diff --git a/roles/ceph-iscsi-gw/tasks/non-container/prerequisites.yml b/roles/ceph-iscsi-gw/tasks/non-container/prerequisites.yml index 52cc0f7586..c36c4d60b7 100644 --- a/roles/ceph-iscsi-gw/tasks/non-container/prerequisites.yml +++ b/roles/ceph-iscsi-gw/tasks/non-container/prerequisites.yml @@ -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: diff --git a/roles/ceph-nfs/tasks/pre_requisite_non_container_debian.yml b/roles/ceph-nfs/tasks/pre_requisite_non_container_debian.yml index 403971aa23..04ebaac678 100644 --- a/roles/ceph-nfs/tasks/pre_requisite_non_container_debian.yml +++ b/roles/ceph-nfs/tasks/pre_requisite_non_container_debian.yml @@ -41,6 +41,7 @@ owner: root group: root backup: yes + when: not offline_install - name: debain based systems - install required packages block: diff --git a/roles/ceph-nfs/tasks/pre_requisite_non_container_red_hat.yml b/roles/ceph-nfs/tasks/pre_requisite_non_container_red_hat.yml index 1829e6d51b..a8431bda13 100644 --- a/roles/ceph-nfs/tasks/pre_requisite_non_container_red_hat.yml +++ b/roles/ceph-nfs/tasks/pre_requisite_non_container_red_hat.yml @@ -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: @@ -63,6 +64,7 @@ when: - ansible_os_family == 'RedHat' - ansible_distribution_major_version == '8' + - not offline_install - name: install pacemaker package: diff --git a/roles/ceph-nfs/tasks/pre_requisite_non_container_ubuntu.yml b/roles/ceph-nfs/tasks/pre_requisite_non_container_ubuntu.yml index ef65622c84..91268f6142 100644 --- a/roles/ceph-nfs/tasks/pre_requisite_non_container_ubuntu.yml +++ b/roles/ceph-nfs/tasks/pre_requisite_non_container_ubuntu.yml @@ -1,5 +1,6 @@ --- - name: ubuntu systems - repo handling + when: not offline_install block: - name: stable repos specific tasks block: diff --git a/roles/ceph-prerun/tasks/main.yml b/roles/ceph-prerun/tasks/main.yml index 3f683884dc..9960cf00ba 100644 --- a/roles/ceph-prerun/tasks/main.yml +++ b/roles/ceph-prerun/tasks/main.yml @@ -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 diff --git a/roles/ceph-prerun/tasks/offline/import_container_images.yml b/roles/ceph-prerun/tasks/offline/import_container_images.yml new file mode 100644 index 0000000000..f7dcb7f6a0 --- /dev/null +++ b/roles/ceph-prerun/tasks/offline/import_container_images.yml @@ -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 diff --git a/roles/ceph-prerun/tasks/offline/import_container_images_docker.yml b/roles/ceph-prerun/tasks/offline/import_container_images_docker.yml new file mode 100644 index 0000000000..f2d153482e --- /dev/null +++ b/roles/ceph-prerun/tasks/offline/import_container_images_docker.yml @@ -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 diff --git a/roles/ceph-prerun/tasks/offline/import_container_images_podman.yml b/roles/ceph-prerun/tasks/offline/import_container_images_podman.yml new file mode 100644 index 0000000000..9572c1d87a --- /dev/null +++ b/roles/ceph-prerun/tasks/offline/import_container_images_podman.yml @@ -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 diff --git a/roles/ceph-prerun/tasks/offline/repo_setup.yml b/roles/ceph-prerun/tasks/offline/repo_setup.yml index 26ce6adc24..a6ab2a242b 100644 --- a/roles/ceph-prerun/tasks/offline/repo_setup.yml +++ b/roles/ceph-prerun/tasks/offline/repo_setup.yml @@ -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 @@ -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 diff --git a/roles/ceph-prerun/tasks/offline/repo_setup_redhat.yml b/roles/ceph-prerun/tasks/offline/repo_setup_redhat.yml index fb23892398..98b23b657e 100644 --- a/roles/ceph-prerun/tasks/offline/repo_setup_redhat.yml +++ b/roles/ceph-prerun/tasks/offline/repo_setup_redhat.yml @@ -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 diff --git a/roles/ceph-prerun/tasks/offline/repo_setup_ubuntu.yml b/roles/ceph-prerun/tasks/offline/repo_setup_ubuntu.yml index aa4d9df993..0e46cc179f 100644 --- a/roles/ceph-prerun/tasks/offline/repo_setup_ubuntu.yml +++ b/roles/ceph-prerun/tasks/offline/repo_setup_ubuntu.yml @@ -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 diff --git a/roles/ceph-prerun/templates/Rocky-Offline.repo.j2 b/roles/ceph-prerun/templates/Rocky-Offline.repo.j2 new file mode 100644 index 0000000000..47c825996b --- /dev/null +++ b/roles/ceph-prerun/templates/Rocky-Offline.repo.j2 @@ -0,0 +1,100 @@ +[45drives-stable-local] +enabled = 1 +priority = 1 +gpgcheck = 1 +repo_gpgcheck = 1 +baseurl = http://{{ offline_repo_server_ip }}/packages/45drives_stable +gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-45drives +name = 45Drives EL8 Stable + +[ceph-iscsi-local] +name=ceph-iscsi noarch packages +baseurl=http://{{ offline_repo_server_ip }}/packages/ceph-iscsi +enabled=1 +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ceph +type=rpm-md + +[nfs_ganesha_stable] +baseurl=http://{{ offline_repo_server_ip }}/packages/nfs_ganesha_stable/ +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ceph +name=nfs-ganesha stable repo + +[nfs_ganesha_stable_noarch] +baseurl=http://{{ offline_repo_server_ip }}/packages/nfs_ganesha_stable_noarch/ +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ceph +name=nfs-ganesha stable noarch repo + +[ceph-stable-local] +baseurl = http://{{ offline_repo_server_ip }}/packages/ceph_stable +gpgcheck = 1 +gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ceph +name = Ceph Stable $basearch repo +priority = 2 + +[ceph-stable-noarch-local] +baseurl = http://{{ offline_repo_server_ip }}/packages/ceph_stable_noarch +gpgcheck = 1 +gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ceph +name = Ceph Stable noarch repo +priority = 2 + +[epel-local] +name=Extra Packages for Enterprise Linux $releasever - $basearch +baseurl=http://{{ offline_repo_server_ip }}/packages/epel +enabled=1 +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8 +exclude=epel-release* + +[epel-modular-local] +name=Extra Packages for Enterprise Linux Modular $releasever - $basearch +baseurl=http://{{ offline_repo_server_ip }}/packages/epel-modular +enabled=1 +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8 + +[appstream-local] +name=Rocky Linux $releasever - AppStream +baseurl=http://{{ offline_repo_server_ip }}/packages/appstream +gpgcheck=1 +enabled=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial + +[baseos-local] +name=Rocky Linux $releasever - BaseOS +baseurl=http://{{ offline_repo_server_ip }}/packages/baseos +gpgcheck=1 +enabled=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial + +[extras-local] +name=Rocky Linux $releasever - Extras +baseurl=http://{{ offline_repo_server_ip }}/packages/extras +gpgcheck=1 +enabled=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial +exclude=epel-release* + +[ha-local] +name=Rocky Linux $releasever - HighAvailability +baseurl=http://{{ offline_repo_server_ip }}/packages/ha +gpgcheck=1 +enabled=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial + +[powertools-local] +name=Rocky Linux $releasever - PowerTools +baseurl=http://{{ offline_repo_server_ip }}/packages/powertools +gpgcheck=1 +enabled=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial + +[zfs-local] +name=ZFS on Linux for EL8 - dkms +baseurl=http://{{ offline_repo_server_ip }}/packages/zfs +enabled=1 +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-zfsonlinux diff --git a/roles/ceph-prerun/vars/main.yml b/roles/ceph-prerun/vars/main.yml index 2558465270..8c7dacbb39 100644 --- a/roles/ceph-prerun/vars/main.yml +++ b/roles/ceph-prerun/vars/main.yml @@ -1,4 +1,18 @@ --- +## OFFLINE MODE ONLY +import_container_images: true +metric_container_images: + - "localhost/grafana-offline:5.4.2" + - "prom/alertmanager:v0.16.2" + - "prom/prometheus:v2.7.2" +metric_container_images_archive: + - "alertmanager-v0.16.2.tar" + - "grafana-v5.4.2.tar" + - "prometheus-v2.7.2.tar" +node_exporter_container_image: "prom/node-exporter:v0.17.0" +node_exporter_container_image_archive: "node-exporter-v0.17.0.tar" +### + ubuntu_install_pkgs: - "45drives-tools" - "python3-docker" @@ -29,9 +43,5 @@ rocky_cleanup_pkgs: - "cockpit-zfs-manager" - "cockpit-machines" -metric_docker_images: - - "alertmanager-v0.16.2.tar" - - "grafana-v5.4.2.tar" - - "prometheus-v2.7.2.tar" diff --git a/roles/ceph-smb/templates/etc/ctdb/nodes.j2 b/roles/ceph-smb/templates/etc/ctdb/nodes.j2 index 8faa54352d..dd533c46e5 100644 --- a/roles/ceph-smb/templates/etc/ctdb/nodes.j2 +++ b/roles/ceph-smb/templates/etc/ctdb/nodes.j2 @@ -1,3 +1,3 @@ {% for host in groups['smbs'] %} -{{ hostvars[host]['ansible_default_ipv4']['address']}} +{{ hostvars[host]['ansible_default_ipv4']['address']|default(hostvars[host]['ansible_all_ipv4_addresses'][0])}} {% endfor %}