From bd4088f25f6f03a47c1a9816e80959dc11ba5b45 Mon Sep 17 00:00:00 2001 From: Alina Buzachis Date: Wed, 18 Oct 2023 11:17:58 +0200 Subject: [PATCH] Revision after running on awx Signed-off-by: Alina Buzachis --- playbooks/move_vm_from_on_prem_to_aws/README.md | 2 +- .../move_vm_from_on_prem_to_aws.yml | 2 +- roles/clone_on_prem_vm/README.md | 2 +- roles/clone_on_prem_vm/tasks/main.yml | 6 ++---- roles/import_image_and_run_aws_instance/README.md | 8 ++++---- roles/import_image_and_run_aws_instance/tasks/main.yml | 4 ++-- 6 files changed, 11 insertions(+), 13 deletions(-) diff --git a/playbooks/move_vm_from_on_prem_to_aws/README.md b/playbooks/move_vm_from_on_prem_to_aws/README.md index 9dd9ea68..57e9947a 100644 --- a/playbooks/move_vm_from_on_prem_to_aws/README.md +++ b/playbooks/move_vm_from_on_prem_to_aws/README.md @@ -39,5 +39,5 @@ All the variables defined in section ``Playbook Variables`` can be defined insid Run the playbook: ```shell -ansible-playbook cloud.aws_ops.move_vm_from_on_prem_to_aws -e "@credentials.yml" -e "@vars.yml" -i inventory.yml +ansible-playbook cloud.aws_ops.move_vm_from_on_prem_to_aws.move_vm_from_on_prem_to_aws -e "@credentials.yml" -e "@vars.yml" -i inventory.yml ``` diff --git a/playbooks/move_vm_from_on_prem_to_aws/move_vm_from_on_prem_to_aws.yml b/playbooks/move_vm_from_on_prem_to_aws/move_vm_from_on_prem_to_aws.yml index fbcc5d1b..d14b752e 100644 --- a/playbooks/move_vm_from_on_prem_to_aws/move_vm_from_on_prem_to_aws.yml +++ b/playbooks/move_vm_from_on_prem_to_aws/move_vm_from_on_prem_to_aws.yml @@ -26,7 +26,7 @@ name: cloud.aws_ops.import_image_and_run_aws_instance vars: import_image_and_run_aws_instance_bucket_name: "{{ import_image_and_run_aws_instance_bucket_name }}" - import_image_and_run_aws_instance_image_path: "{{ import_image_and_run_aws_instance_image_path }}" + import_image_and_run_aws_instance_image_path: "{{ clone_on_prem_vm_raw_image_path }}" import_image_and_run_aws_instance_instance_name: "{{ import_image_and_run_aws_instance_instance_name }}" import_image_and_run_aws_instance_instance_type: "{{ import_image_and_run_aws_instance_instance_type }}" import_image_and_run_aws_instance_import_image_task_name: "{{ import_image_and_run_aws_instance_import_image_task_name }}" diff --git a/roles/clone_on_prem_vm/README.md b/roles/clone_on_prem_vm/README.md index 4d08d3e9..d850d17b 100644 --- a/roles/clone_on_prem_vm/README.md +++ b/roles/clone_on_prem_vm/README.md @@ -1,7 +1,7 @@ clone_on_prem_vm ================ -A role to clone an existing on prem VM using the KVM hypervisor. The role sets the **clone_on_prem_vm_local_image_path** variable containing the path where the image was saved on localhost. This role requires privilege escalation because the .qcow2 file created by ``virt-clone`` is owned by root and ``qemu-img convert`` requires access to convert it to .raw. +A role to clone an existing on prem VM using the KVM hypervisor. The role sets the **clone_on_prem_vm_raw_image_path** variable containing the path where the image was saved on localhost. This role requires privilege escalation because the .qcow2 file created by ``virt-clone`` is owned by root and ``qemu-img convert`` requires access to convert it to .raw. Requirements ------------ diff --git a/roles/clone_on_prem_vm/tasks/main.yml b/roles/clone_on_prem_vm/tasks/main.yml index 65a9c463..8807f73f 100644 --- a/roles/clone_on_prem_vm/tasks/main.yml +++ b/roles/clone_on_prem_vm/tasks/main.yml @@ -136,11 +136,9 @@ ansible.builtin.fetch: src: "{{ clone_on_prem_vm__raw_image_path }}" dest: "{{ clone_on_prem_vm__dir_localhost.path }}" - flat: yes - fail_on_missing: yes validate_checksum: true register: clone_on_prem_vm_fetch_to_localhost -- name: Set 'clone_on_prem_vm_local_image_path' +- name: Set 'clone_on_prem_vm_raw_image_path' ansible.builtin.set_fact: - clone_on_prem_vm_local_image_path: "{{ clone_on_prem_vm_fetch_to_localhost.dest }}" + clone_on_prem_vm_raw_image_path: "{{ clone_on_prem_vm_fetch_to_localhost.dest }}" diff --git a/roles/import_image_and_run_aws_instance/README.md b/roles/import_image_and_run_aws_instance/README.md index 6413318e..4985a4dd 100644 --- a/roles/import_image_and_run_aws_instance/README.md +++ b/roles/import_image_and_run_aws_instance/README.md @@ -81,7 +81,7 @@ Create a ``playbook.ym`` file like this: --- - hosts: localhost gather_facts: false - + tasks: - name: Import 'cloud.aws_ops.clone_on_prem_vm' role ansible.builtin.import_role: @@ -90,15 +90,15 @@ Create a ``playbook.ym`` file like this: clone_on_prem_vm_source_vm_name: "{{ clone_on_prem_vm_source_vm_name }}" clone_on_prem_vm_image_name: "{{ clone_on_prem_vm_image_name }}" clone_on_prem_vm_local_image_path: "{{ clone_on_prem_vm_local_image_path }}" - clone_on_prem_vm_uri: "{{ clone_on_prem_vm_uri }}" + clone_on_prem_vm_uri: "{{ clone_on_prem_vm_uri }}" delegate_to: kvm - + - name: Import 'cloud.aws_ops.import_image_and_run_aws_instance' role ansible.builtin.import_role: name: cloud.aws_ops.import_image_and_run_aws_instance vars: import_image_and_run_aws_instance_bucket_name: "{{ import_image_and_run_aws_instance_bucket_name }}" - import_image_and_run_aws_instance_image_path: "{{ import_image_and_run_aws_instance_image_path }}" + import_image_and_run_aws_instance_image_path: "{{ clone_on_prem_vm_raw_image_path }}" import_image_and_run_aws_instance_instance_name: "{{ import_image_and_run_aws_instance_instance_name }}" import_image_and_run_aws_instance_instance_type: "{{ import_image_and_run_aws_instance_instance_type }}" import_image_and_run_aws_instance_import_image_task_name: "{{ import_image_and_run_aws_instance_import_image_task_name }}" diff --git a/roles/import_image_and_run_aws_instance/tasks/main.yml b/roles/import_image_and_run_aws_instance/tasks/main.yml index 8d1f9655..e691db52 100644 --- a/roles/import_image_and_run_aws_instance/tasks/main.yml +++ b/roles/import_image_and_run_aws_instance/tasks/main.yml @@ -78,8 +78,8 @@ Values: ["completed", "active"] register: import_image_and_run_aws_instance__import_image_info until: import_image_and_run_aws_instance__import_image_info.import_image[0].status == "completed" - delay: 3 - retries: 30 + delay: 10 + retries: 300 - name: Set 'import_image_and_run_aws_instance__ami_id' and 'import_image_and_run_aws_instance__snapshot_id' ansible.builtin.set_fact: