Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/integ-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
- run: apt install -y jq
- run: mkdir -p $WORKDIR
- run: cp -a ./ $WORKDIR
- run: ansible-galaxy collection install community.general
- run: ansible-galaxy collection install community.crypto community.general
- run: |
cd $WORKDIR
echo "${{ vars.CI_CONFIG_HC_IP50 }}" > tests/integration/integration_config.yml
Expand All @@ -65,6 +65,7 @@ jobs:
ls -al tests/integration/integration_config.yml
- run: cd $WORKDIR && ansible-playbook tests/integration/prepare/prepare_iso.yml
- run: cd $WORKDIR && ansible-playbook tests/integration/prepare/prepare_vm.yml
- run: cd $WORKDIR && ansible-playbook tests/integration/prepare/prepare_examples.yml
if: "${{ github.event.inputs.integ_tests_include || github.event.schedule }}"

integ-matrix:
Expand Down Expand Up @@ -165,7 +166,7 @@ jobs:
eval export SC_USERNAME=$(cat tests/integration/integration_config.yml | yq '.sc_username')
eval export SC_PASSWORD=$(cat tests/integration/integration_config.yml | yq '.sc_password')
eval export SC_TIMEOUT=$(cat tests/integration/integration_config.yml | yq '.sc_timeout')
ansible-playbook --check examples/${{ matrix.example_name }}
ansible-playbook -i localhost, -e hypercore_example_check_mode=true examples/${{ matrix.example_name }}

integ:
needs:
Expand Down
4 changes: 4 additions & 0 deletions examples/certificate_signing_example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
hosts: localhost
connection: local
gather_facts: false
vars:
hypercore_example_check_mode: "{{ ansible_check_mode }}"

tasks:
# More info about openssl_privatekey module
Expand Down Expand Up @@ -40,6 +42,8 @@
private_key: "{{ lookup('file', 'private_key_example.pem') }}"
certificate: "{{ lookup('file', 'certificate_example.crt') }}"
register: certificate_info
# This is problematic, it would restart API server
check_mode: "{{ hypercore_example_check_mode }}"

- name: Show uploaded certificate info
debug:
Expand Down
13 changes: 7 additions & 6 deletions examples/dns_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
dns_servers:
- 1.2.3.4
- 5.6.7.8
state: set
state: after # or before

# ------------------------------------------------------
# Configure system with valid DNS resolvers
- name: Modify existing DNS config configurations
scale_computing.hypercore.dns_config:
search_domains:
- example.domain.com
search_domains: []
dns_servers:
- 0.0.0.1
- 0.0.1.0
state: before # or after
- 1.1.1.1
- 1.0.0.1
state: set
3 changes: 3 additions & 0 deletions examples/email_alert.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
vars:
email: example@example.com
email_new: new@example.com
hypercore_example_check_mode: "{{ ansible_check_mode }}"

tasks:
- name: Create Email alert recipient
Expand All @@ -17,6 +18,8 @@
scale_computing.hypercore.email_alert:
email: "{{ email }}"
state: test
# Sending test can fail (invalid email, or invalid SMTP server).
check_mode: "{{ hypercore_example_check_mode }}"

- name: Modify previously created Email alert recipient
scale_computing.hypercore.email_alert:
Expand Down
6 changes: 5 additions & 1 deletion examples/list_vms_with_ide_disk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
break
print(json.dumps(ide_vm_names))
args:
executable: /usr/bin/python3
# /usr/bin/python3 - fedora
# /usr/local/bin/python - python:3.10-slim-buster docker image
executable: python3
stdin: "{{ all_vms.records | to_json }}"
changed_when: false
register: ide_vm_names_result
Expand All @@ -53,3 +55,5 @@
ansible.builtin.fail:
msg: Found {{ ide_vm_names | length }} VMs using IDE disk
when: ide_vm_names | length > 0
# VMs with IDE disks are created while testing. Ignore them if testing.
ignore_errors: "{{ hypercore_example_check_mode | default(false) }}"
2 changes: 2 additions & 0 deletions examples/smtp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
hosts: localhost
connection: local
gather_facts: false
# Example is safe to run - if we do not modify from_address
check_mode: true
vars:
smtp_server: smtp-relay.gmail.com
smtp_port: 25
Expand Down
2 changes: 2 additions & 0 deletions examples/time_server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
hosts: localhost
connection: local
gather_facts: false
# NTP is always a bit problemtic for reconfiguration
check_mode: true
vars:
source: pool.ntp.org

Expand Down
2 changes: 1 addition & 1 deletion examples/time_zone_info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

tasks:
- name: List current Time Zone entries
- scale_computing.hypercore.time_zone_info:
scale_computing.hypercore.time_zone_info:
register: time_zone_info
- ansible.builtin.debug:
msg: "{{ time_zone_info }}"
11 changes: 0 additions & 11 deletions examples/virtual_disk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
# image_url: https://github.com/ddemlow/RestAPIExamples/blob/master/ubuntu18_04-cloud-init/ubuntu18cloudimage.qcow2
image_filename: "{{ image_url | split('/') | last }}"
image_remove_old: false
sc_host: https://10.100.20.38 # TODO
sc_username: admin
sc_password: admin

tasks:
# # ------------------------------------------------------
Expand Down Expand Up @@ -39,10 +36,6 @@
- name: Upload Virtual Disk {{ image_filename }} to HyperCore
scale_computing.hypercore.api:
action: put
cluster_instance:
host: "{{ sc_host }}"
username: "{{ sc_username }}"
password: "{{ sc_password }}"
endpoint: /rest/v1/VirtualDisk/upload
data:
filename: "{{ image_filename }}"
Expand All @@ -54,10 +47,6 @@
- name: Get Information About the uploaded Virtual Disk in HyperCore
scale_computing.hypercore.api:
action: get
cluster_instance:
host: "{{ sc_host }}"
username: "{{ sc_username }}"
password: "{{ sc_password }}"
endpoint: /rest/v1/VirtualDisk/{{ uploadResult.record.createdUUID }}
register: result

Expand Down
44 changes: 44 additions & 0 deletions tests/integration/prepare/prepare_examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
- name: Create resources for testing examples
hosts: localhost
connection: local
vars:
cluster_instance:
host: "{{ sc_host }}"
username: "{{ sc_username }}"
password: "{{ sc_password }}"
timeout: "{{ sc_timeout }}"
vars_files:
- ../integration_config.yml

tasks:
- name: Debug show SC_HOST
ansible.builtin.debug:
msg: SC_HOST={{ lookup('ansible.builtin.env', 'SC_HOST') }} sc_host={{ sc_host }}

# For examples/vm_replication_info.yml
- name: Create VM demo-vm for examples/vm_replication_info.yml
scale_computing.hypercore.vm:
cluster_instance: "{{ cluster_instance }}"
vm_name: demo-vm
description: demo-vm
state: present
tags:
- Xlab
memory: "{{ '512 MB' | human_to_bytes }}"
vcpu: 1
attach_guest_tools_iso: false
power_state: stop
disks:
- type: virtio_disk
disk_slot: 0
size: "{{ '1.1 GB' | human_to_bytes }}"
nics:
- vlan: 1
type: RTL8139
boot_devices:
- type: virtio_disk
disk_slot: 0
- type: nic
nic_vlan: 1
machine_type: BIOS