Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address ansible-lint reported issues #4056

Merged
merged 3 commits into from
Oct 17, 2023
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
2 changes: 1 addition & 1 deletion molecule/docker/create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
content: |
{{ molecule_inventory | to_yaml }}
dest: "{{ molecule_ephemeral_directory }}/inventory/molecule_inventory.yml"
mode: 0600
mode: "0600"

- name: Force inventory refresh
ansible.builtin.meta: refresh_inventory
Expand Down
12 changes: 6 additions & 6 deletions molecule/kubevirt/create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
temporary_ssh_key_size: 2048 # Variable for the size of the SSH key
tasks:
- name: Set default SSH key path # Sets the path of the SSH key
set_fact:
ansible.builtin.set_fact:
tempoary_ssh_key_path: "{{ molecule_ephemeral_directory }}/identity_file"

- name: Generate SSH key pair # Generates a new SSH key pair
Expand All @@ -16,16 +16,17 @@
register: temporary_ssh_keypair # Stores the output of this task in a variable

- name: Set SSH public key # Sets the SSH public key from the key pair
set_fact:
ansible.builtin.set_fact:
temporary_ssh_public_key: "{{ temporary_ssh_keypair.public_key }}"

- name: Create VM in KubeVirt # Calls another file to create the VM in KubeVirt
include_tasks: tasks/create_vm.yml
ansible.builtin.include_tasks: tasks/create_vm.yml
loop: "{{ molecule_yml.platforms }}" # Loops over all platforms defined in molecule_yml
loop_control:
loop_var: vm # Sets the variable for the current item in the loop

- name: Create Nodeport service if ssh_type is set to NodePort # Conditional block, executes if vm.ssh_service.type is NodePort
when: "vm.ssh_service.type == 'NodePort'" # The block is executed when this condition is met
block:
- name: Create ssh NodePort Kubernetes Services # Creates a new NodePort service in Kubernetes
kubernetes.core.k8s:
Expand Down Expand Up @@ -58,10 +59,9 @@
loop_control:
loop_var: vm # Sets the variable for the current item in the loop
register: node_port_services # Stores the output of this task in a variable
when: "vm.ssh_service.type == 'NodePort'" # The block is executed when this condition is met

- name: Create VM dictionary # Calls another file to create a dictionary with information about the VM
include_tasks: tasks/create_vm_dictionary.yml
ansible.builtin.include_tasks: tasks/create_vm_dictionary.yml
loop: "{{ molecule_yml.platforms }}" # Loops over all platforms defined in molecule_yml
loop_control:
loop_var: vm # Sets the variable for the current item in the loop
Expand All @@ -76,7 +76,7 @@
ansible.builtin.copy:
content: "{{ molecule_inventory | to_nice_yaml }}"
dest: "{{ molecule_ephemeral_directory }}/inventory/molecule_inventory.yml"
mode: 0600 # Sets the permissions of the file to -rw-------
mode: "0600" # Sets the permissions of the file to -rw-------

- name: Refresh inventory # Refreshes the inventory
ansible.builtin.meta: refresh_inventory
Expand Down
4 changes: 2 additions & 2 deletions molecule/kubevirt/tasks/create_vm_dictionary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
ssh_service_address: >-
{%- set svc_type = vm.ssh_service.type | default(None) -%}
{%- if svc_type == 'NodePort' -%}
{{(node_port_services.results | selectattr('vm.name','==',vm.name) | first)['resources'][0]['spec']['ports'][0]['nodePort'] }}
{{ (node_port_services.results | selectattr('vm.name', '==', vm.name) | first)['resources'][0]['spec']['ports'][0]['nodePort'] }}
{%- endif -%}
set_fact:
ansible.builtin.set_fact:
# Here, the task is updating the `molecule_systems` dictionary with new VM information.
# If `molecule_systems` doesn't exist, it is created as an empty dictionary.
# Then it is combined with a new dictionary for the current VM, containing ansible connection details.
Expand Down
2 changes: 1 addition & 1 deletion molecule/podman/create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
content: |
{{ molecule_inventory | to_yaml }}
dest: "{{ molecule_ephemeral_directory }}/inventory/molecule_inventory.yml"
mode: 0600
mode: "0600"

- name: Force inventory refresh
ansible.builtin.meta: refresh_inventory
Expand Down
10 changes: 6 additions & 4 deletions playbooks/snap-pre-run.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
- hosts: all
- name: Snap-pre-run
hosts: all
become: true
tasks:
- name: Install snapd
Expand All @@ -11,13 +12,14 @@
name: snapd.socket
state: started

- when: ansible_os_family == 'Debian'
name: Install snapcraft (debian)
- name: Install snapcraft (debian)
when: ansible_os_family == 'Debian'
ansible.builtin.package:
name: snapcraft
state: present

- when: ansible_os_family == 'RedHat'
- name: Install snapcraft (RedHat)
when: ansible_os_family == 'RedHat'
block:
- name: Activate snapd
ansible.builtin.shell: |
Expand Down