From 59775999d8992d8287a06f5bd1854ebe4cecd6b2 Mon Sep 17 00:00:00 2001 From: Yolanda Robla Date: Thu, 18 Mar 2021 17:22:46 +0100 Subject: [PATCH] Reconcile latest changes with SNO Use the common roles to execute regular tasks, to avoid duplicates Signed-off-by: Yolanda Robla --- .../inventory/hosts.sample | 3 + .../roles/create-cluster/tasks/main.yml | 56 +++++-------------- .../roles/deploy-cluster/tasks/main.yml | 23 ++++---- .../roles/prepare-environment/tasks/main.yml | 32 +++-------- common-roles/download-iso/tasks/main.yml | 2 +- .../install-assisted-installer/tasks/main.yml | 4 +- common-roles/install-httpd/tasks/main.yml | 22 ++++++++ 7 files changed, 64 insertions(+), 78 deletions(-) create mode 100644 common-roles/install-httpd/tasks/main.yml diff --git a/ai-deploy-cluster-singlenode/inventory/hosts.sample b/ai-deploy-cluster-singlenode/inventory/hosts.sample index 9b56b63..6925deb 100644 --- a/ai-deploy-cluster-singlenode/inventory/hosts.sample +++ b/ai-deploy-cluster-singlenode/inventory/hosts.sample @@ -48,6 +48,9 @@ final_iso_path=/var/www/html # final_iso_path=/home/share/ # need_racadm=false +# if virtualmedia is done over http +virtualmedia_over_http=True + ### Network config (uncomment for static setting, or leave commented for DHCP) # it needs to follow nmstate format # network_config_path=./sample/worker_sno.yaml diff --git a/ai-deploy-cluster-singlenode/roles/create-cluster/tasks/main.yml b/ai-deploy-cluster-singlenode/roles/create-cluster/tasks/main.yml index 2e919ae..53079a9 100644 --- a/ai-deploy-cluster-singlenode/roles/create-cluster/tasks/main.yml +++ b/ai-deploy-cluster-singlenode/roles/create-cluster/tasks/main.yml @@ -1,43 +1,15 @@ --- -- name: Create a temporary file - tempfile: - state: file - register: tempfile_pullsecret - -- name: Copy pull secret to file - copy: - content: "{{ pull_secret }}" - dest: "{{ tempfile_pullsecret.path }}" - -- name: Create cluster and download ISO - block: - - name: Create new AI cluster - shell: "aicli create cluster -P pull_secret={{ tempfile_pullsecret.path }} -P base_dns_domain={{ cluster_domain }} -P ssh_public_key='{{ ssh_public_key }}' -P high_availability_mode=None -P openshift_version='{{ cluster_version }}' {{ cluster_name }}" - - - name: Retrieve cluster ID from name - shell: "aicli list cluster | grep {{ cluster_name }} | cut -d '|' -f3 | tr -d ' '" - register: cluster_id - - - name: Set the right network type - uri: - url: "{{ ai_url }}/api/assisted-install/v1/clusters/{{ cluster_id.stdout }}/install-config" - method: PATCH - body: '"{\"networking\": {\"networkType\": \"{{ cluster_sdn | default("OVNKubernetes") }}\"}}"' - body_format: json - status_code: 201 - - - name: Copy the network file remotely if it exists - copy: - src: "{{ network_config_path }}" - dest: "{{ temporary_path }}/network_config" - when: network_config_path is defined and network_config_path|length>0 - - - name: Download the small ISO - shell: "aicli create iso --minimal -P ssh_public_key='{{ ssh_public_key}}' {% if network_config_path is defined and network_config_path|length > 0 %}--paramfile {{ temporary_path }}/network_config{% endif %} {{ cluster_name }}" - - - name: And download it - shell: "aicli download iso {{ cluster_name }} -p {{ final_iso_path }}" - - environment: - AI_URL: "{{ ai_url }}" - +- name: create cluster + include_role: + name: "{{ playbook_dir }}/../common-roles/create-cluster" + vars: + extra_args: "-P high_availability_mode=None" + cluster_name_var: "{{ cluster_name }}" + +- name: download ISO + include_role: + name: "{{ playbook_dir }}/../common-roles/download-iso" + vars: + cluster_name_var: "{{ cluster_name }}" + final_iso_path_var: "{{ final_iso_path }}" + minimal: True diff --git a/ai-deploy-cluster-singlenode/roles/deploy-cluster/tasks/main.yml b/ai-deploy-cluster-singlenode/roles/deploy-cluster/tasks/main.yml index 8e7c09e..052dc06 100644 --- a/ai-deploy-cluster-singlenode/roles/deploy-cluster/tasks/main.yml +++ b/ai-deploy-cluster-singlenode/roles/deploy-cluster/tasks/main.yml @@ -1,17 +1,20 @@ --- -- name: Configure cluster +- name: Configure host block: - - block: - - name: Query for the host ID, there is only one as is SNO - shell: "aicli list hosts | grep {{ cluster_name }} | cut -d '|' -f 4" - register: host_id - when: hostname is defined - - - name: Set the hostname for the given host_id - shell: "aicli update host {{ host_id.stdout | trim }} -P name={{ hostname }}" - when: host_id | length > 0 + - name: Query for the host ID, there is only one as is SNO + shell: "aicli list hosts | grep {{ cluster_name }} | cut -d '|' -f 4" + register: host_id when: hostname is defined + - name: Set the hostname for the given host_id + shell: "aicli update host {{ host_id.stdout | trim }} -P name={{ hostname }}" + when: host_id | length > 0 + when: hostname is defined + environment: + AI_URL: "{{ ai_url }}" + +- name: Configure cluster + block: - name: Wait until cluster is ready to be installed shell: "aicli list cluster | grep {{ cluster_name }} | cut -d '|' -f4 | tr -d ' '" register: cluster_ready diff --git a/ai-deploy-cluster-singlenode/roles/prepare-environment/tasks/main.yml b/ai-deploy-cluster-singlenode/roles/prepare-environment/tasks/main.yml index 2c8b015..3d6a610 100644 --- a/ai-deploy-cluster-singlenode/roles/prepare-environment/tasks/main.yml +++ b/ai-deploy-cluster-singlenode/roles/prepare-environment/tasks/main.yml @@ -5,24 +5,12 @@ - podman - openssl-devel - make - - httpd state: present -- name: make sure httpd landing page is disabled - copy: - content: "# Disabled" - dest: /etc/httpd/conf.d/welcome.conf - force: yes - group: root - owner: root - mode: 0644 - -- name: Enable and (re)start httpd - systemd: - name: httpd - enabled: yes - masked: no - state: restarted +- name: install httpd + include_role: + name: "{{ playbook_dir }}/../common-roles/install-httpd" + when: virtualmedia_over_http is defined and virtualmedia_over_http|bool == True - name: Set openshift_versions json dict ansible.builtin.set_fact: @@ -31,18 +19,18 @@ "display_name": "{{ display_name }}", "rhcos_image": "{{ rhcos_image }}", "rhcos_version": "{{ rhcos_version }}", - "support_level": "{{ support_level }}"}}' + "support_level": "{{ support_level | default("beta") }}" +} +}' + - name: Set openshift_versions json object ansible.builtin.set_fact: openshift_versions: "{{ openshift_versions_dict | to_json }}" + - name: Set rhcos_base_iso to rhcos_image to avoid duplication ansible.builtin.set_fact: rhcos_base_iso: "{{ rhcos_image }}" -- name: install ISO generator scripts - include_role: - name: "{{ playbook_dir }}/../common-roles/install-iso-generator" - - name: install racadm include_role: name: "{{ playbook_dir }}/../common-roles/install-racadm" @@ -64,5 +52,3 @@ - "OPENSHIFT_INSTALL_RELEASE_IMAGE={{ sno_image }}" - "PUBLIC_CONTAINER_REGISTRIES=quay.io,registry.svc.ci.openshift.org" - "RHCOS_BASE_ISO={{ rhcos_base_iso }}" - - diff --git a/common-roles/download-iso/tasks/main.yml b/common-roles/download-iso/tasks/main.yml index 8dcf53b..d624e5f 100644 --- a/common-roles/download-iso/tasks/main.yml +++ b/common-roles/download-iso/tasks/main.yml @@ -12,7 +12,7 @@ when: network_config_path is defined and network_config_path|length>0 - name: Create the small ISO - shell: "aicli create iso {% if minimal is defined and minimal | bool == True%}--minimal{% endif %} -P ssh_public_key='{{ ssh_public_key}}' --paramfile {% if network_config_path is defined and network_config_path|length > 0 %}{{ temporary_path }}/network_config{% endif %} {{ cluster_name_var }}" + shell: "aicli create iso {% if minimal is defined and minimal | bool == True%}--minimal{% endif %} -P ssh_public_key='{{ ssh_public_key}}' {% if network_config_path is defined and network_config_path|length > 0 %}--paramfile {{ temporary_path }}/network_config{% endif %} {{ cluster_name_var }}" - name: And download it shell: "aicli download iso {{ cluster_name_var }} -p {{ final_iso_path_var }}" diff --git a/common-roles/install-assisted-installer/tasks/main.yml b/common-roles/install-assisted-installer/tasks/main.yml index 89216ff..cfa67a6 100644 --- a/common-roles/install-assisted-installer/tasks/main.yml +++ b/common-roles/install-assisted-installer/tasks/main.yml @@ -1,7 +1,7 @@ - name: Clone the assisted installer project git: repo: 'https://github.com/openshift/assisted-service' - version: "{{ ai_version }}" + version: "{{ ai_version | default('HEAD') }}" dest: /opt/assisted-service-ztp update: yes force: yes @@ -35,7 +35,7 @@ chdir: "/opt/assisted-service-ztp" - name: Start the assisted installer service - shell: "ASSISTED_TAG={{ assisted_tag }} make deploy-onprem" + shell: "ASSISTED_TAG={{ assisted_tag | default('latest') }} make deploy-onprem" args: chdir: "/opt/assisted-service-ztp" environment: diff --git a/common-roles/install-httpd/tasks/main.yml b/common-roles/install-httpd/tasks/main.yml new file mode 100644 index 0000000..62d30d2 --- /dev/null +++ b/common-roles/install-httpd/tasks/main.yml @@ -0,0 +1,22 @@ +--- +- name: Install httpd package + yum: + name: + - httpd + state: present + +- name: make sure httpd landing page is disabled + copy: + content: "# Disabled" + dest: /etc/httpd/conf.d/welcome.conf + force: yes + group: root + owner: root + mode: 0644 + +- name: Enable and (re)start httpd + systemd: + name: httpd + enabled: yes + masked: no + state: restarted