Skip to content

Commit

Permalink
rebase branch
Browse files Browse the repository at this point in the history
  • Loading branch information
OrrBG committed Jan 7, 2025
1 parent 849e788 commit e69f822
Show file tree
Hide file tree
Showing 9 changed files with 149 additions and 0 deletions.
7 changes: 7 additions & 0 deletions playbooks/upload_iso_to_datastore.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- name: Upload local ISO file to Datastore
hosts: all
gather_facts: false

roles:
- role: cloud.vmware_ops.upload_iso_to_datastore
Empty file.
9 changes: 9 additions & 0 deletions roles/upload_iso_to_datastore/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
upload_iso_to_datastore_hostname: "{{ vmware_ops_collection_hostname }}"
upload_iso_to_datastore_username: "{{ vmware_ops_collection_username }}"
upload_iso_to_datastore_password: "{{ vmware_ops_collection_password }}"
upload_iso_to_datastore_validate_certs: "{{ vmware_ops_collection_validate_certs }}"
upload_iso_to_datastore_port: "{{ vmware_ops_collection_port }}"

upload_iso_to_datastore_proxy_host: "{{ vmware_ops_collection_proxy_host }}"
upload_iso_to_datastore_proxy_port: "{{ vmware_ops_collection_proxy_port }}"
12 changes: 12 additions & 0 deletions roles/upload_iso_to_datastore/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
galaxy_info:
author: Ansible Cloud Content Team (@redhat-cop)
description: Manage a content library in vCenter
company: Red Hat, Inc.
license: GPL-3.0-or-later
min_ansible_version: "2.13"
galaxy_tags:
- infrastructure
- vmware

dependencies: []
25 changes: 25 additions & 0 deletions roles/upload_iso_to_datastore/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
- name: Import Collection Level Vars
ansible.builtin.include_vars:
file: "{{ role_path }}/../../vars/main.yml"

- name: Check Mandatory Variables Are Defined
ansible.builtin.assert:
that:
- upload_iso_to_datastore_hostname is defined
- upload_iso_to_datastore_username is defined
- upload_iso_to_datastore_password is defined
- upload_iso_to_datastore_datastore is defined
quiet: true
fail_msg: Variable must be set when using this role.

- name: Upload local ISO file to Datastore
community.vmware.vsphere_copy:
hostname: "{{ upload_iso_to_datastore_hostname }}"
username: "{{ upload_iso_to_datastore_username }}"
password: "{{ upload_iso_to_datastore_password }}"
src: "{{ upload_iso_to_datastore_src }}"
datacenter: "{{ upload_iso_to_datastore_datacenter }}"
datastore: "{{ upload_iso_to_datastore_datastore }}"
path: "{{ upload_iso_to_datastore_dst}}"
validate_certs: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
- hosts: localhost
gather_facts: no

tasks:
- name: Import eco-vcenter credentials
ansible.builtin.include_vars:
file: ../../integration_config.yml
tags: eco-vcenter-ci

- name: Import Upload ISO to Datastore role
ansible.builtin.import_role:
name: vmware_ops_upload_iso_to_datastore_test
tags:
- eco-vcenter-ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
- name: Test
when: not run_on_simulator
block:
- name: Import common vars
ansible.builtin.include_vars:
file: ../group_vars.yml

- name: Create ISO Mocks
block:
- name: Mock VCSA Binary
ansible.builtin.include_tasks: mock_vcsa_binary.yml
always:
- name: Clean Up Temp Files
ansible.builtin.file:
path: "{{ provision_vcenter_test_mock_binary_root }}"
state: absent

- name: Test ISO Upload to Datastore
block:
- name: Upload ISO to Datastore
ansible.builtin.import_role:
name: cloud.vmware_ops.upload_iso_to_datastore

- name: Attempt to recreate ISO file
community.vmware.vsphere_file:
hostname: '{{ upload_iso_to_datastore_hostname }}'
username: '{{ upload_iso_to_datastore_username }}'
password: '{{ upload_iso_to_datastore_password }}'
datacenter: "{{ upload_iso_to_datastore_datacenter }}"
datastore: "{{ upload_iso_to_datastore_datastore }}"
path: "{{ upload_iso_to_datastore_dst }}"
state: file
validate_certs: false
ignore_errors: true
register: file_result

- name: Check ISO was copied to Datastore
ansible.builtin.assert:
that:
- file_result.changed is false
quiet: true
fail_msg: Copy of ISO was unsuccessful

always:
- name: Clean Up Temp ISO
ansible.builtin.file:
path: "{{ upload_iso_to_datastore_src }}"
state: absent

- name: Delete ISO file from Datastore
community.vmware.vsphere_file:
hostname: "{{ upload_iso_to_datastore_hostname }}"
username: "{{ upload_iso_to_datastore_username }}"
password: "{{ upload_iso_to_datastore_password }}"
state: absent
datacenter: "{{ upload_iso_to_datastore_datacenter }}"
datastore: "{{ upload_iso_to_datastore_datastore }}"
path: "{{ upload_iso_to_datastore_dst}}"
validate_certs: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
- name: Create Mock VCSA Deployment Binary Path
ansible.builtin.file:
path: "{{ provision_vcenter_test_mock_binary_root }}/lin64"
state: directory

- name: Create Mock VCSA ISO file
community.general.iso_create:
src_files:
- "{{ provision_vcenter_test_mock_binary_root }}"
dest_iso: "{{ upload_iso_to_datastore_src }}"
interchange_level: 4
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
run_on_simulator: false

upload_iso_to_datastore_datacenter: "{{ vcenter_datacenter }}"
upload_iso_to_datastore_datastore: "{{ shared_storage_01 }}"
upload_iso_to_datastore_src: "/tmp/test.iso"
upload_iso_to_datastore_dst: "/test.iso"

provision_vcenter_test_mock_binary_root: /tmp/vcsa-cli-installer

0 comments on commit e69f822

Please sign in to comment.