Skip to content

Commit

Permalink
Revision after running on awx
Browse files Browse the repository at this point in the history
Signed-off-by: Alina Buzachis <[email protected]>
  • Loading branch information
alinabuzachis committed Oct 18, 2023
1 parent 4e5a4ab commit bd4088f
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion playbooks/move_vm_from_on_prem_to_aws/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand Down
2 changes: 1 addition & 1 deletion roles/clone_on_prem_vm/README.md
Original file line number Diff line number Diff line change
@@ -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
------------
Expand Down
6 changes: 2 additions & 4 deletions roles/clone_on_prem_vm/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
8 changes: 4 additions & 4 deletions roles/import_image_and_run_aws_instance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 }}"
Expand Down
4 changes: 2 additions & 2 deletions roles/import_image_and_run_aws_instance/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit bd4088f

Please sign in to comment.