Skip to content

Commit bc38d0b

Browse files
committed
fixes to 03
1 parent 3b0b08f commit bc38d0b

File tree

1 file changed

+23
-60
lines changed

1 file changed

+23
-60
lines changed

content/modules/ROOT/pages/03-vm-management.adoc

Lines changed: 23 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,9 @@ $ cd collections/ansible_collections/redhatone/vm_management/roles/vm_management
5050
This Ansible playbook dynamically calls the role and executes the appropriate
5151
task based on the `task_file` variable given.
5252

53-
. Navigate to your `virt-aap-day2` directory
53+
. Within your VSCode editor, right click `virt-aap-day2` and create a New File labeled `manage_vm_playbook.yml`
5454
+
55-
----
56-
$ cd /home/lab-user/virt-aap-day2
57-
----
58-
+
59-
. Create a manage_vm_playbook.yml file
60-
+
61-
----
62-
$ touch manage_vm_playbook.yml
63-
----
64-
+
65-
. Using your favorite editor, create the following Ansible Playbook:
55+
. Add the following content to the `manage_vm_playbook.yml`
6656
+
6757
----
6858
---
@@ -72,7 +62,7 @@ $ touch manage_vm_playbook.yml
7262
- redhatone.vm_management.vm_management
7363
----
7464
+
75-
. After making and saving the changes, ensure you commit and push them to your Gitea repository.
65+
. After making and saving the changes, ensure you commit and push them to your Gitea repository. For detailed instructions, refer to xref:appendix-vscode-commit-push.adoc[].
7666

7767
=== Stop a VM Task
7868

@@ -81,21 +71,11 @@ included in the `vm_management` role, specifically under the `tasks` directory,
8171
in a file named `stop_vm.yml`. Later in the lab, you will call this task from an
8272
Ansible playbook to demonstrate its capability.
8373

84-
. Navigate to the Tasks Directory:
74+
. Within your VSCode editor, right click `tasks` of the `vm_management` collection and create a New File labeled `stop_vm.yml`
8575
+
86-
* Inside your `vm_management` role directory, go to the `tasks` folder:
76+
image::new_file.png[title='New File Creation', link=self, window=blank]
8777
+
88-
----
89-
$ cd collections/ansible_collections/redhatone/vm_management/roles/vm_management/tasks/
90-
----
91-
+
92-
. Create the `stop_vm.yml` file
93-
+
94-
----
95-
touch stop_vm.yml
96-
----
97-
+
98-
. Open the `stop_vm.yml` file with your favorite editor and add the following task
78+
. Add the following content to the `stop_vm.yml`
9979
+
10080
----
10181
---
@@ -114,7 +94,7 @@ Explanation of the Task:
11494
* The `running: false` ensures the VM is not running
11595
* The `wait: true` ensures the next Ansible task isn't triggered until the stop is complete
11696
+
117-
. After making and saving the changes, ensure you commit and push them to your Gitea repository.
97+
. After making and saving the changes, ensure you commit and push them to your Gitea repository. For detailed instructions, refer to xref:appendix-vscode-commit-push.adoc[].
11898

11999
=== Create & Run a Job Template with Ansible Automation Platform
120100

@@ -164,11 +144,9 @@ Virtual Machines that reside within the `vms-aap-day2` namespace and learn how
164144
to use the debug task to understand the structure of the VM resource `vm_info`
165145
to identify key fields required to create dynamic Ansible tasks.
166146

167-
. Access the `stop_vm.yml` file using your favorite editor
168-
+
169-
----
170-
$ cd collections/ansible_collections/redhatone/vm_management/roles/vm_management/tasks/
171-
----
147+
148+
149+
. Head back to the VSCode editor to Access the `stop_vm.yml` file
172150
+
173151
. Modify the existing `stop_vm.yml` content with the following:
174152
+
@@ -238,8 +216,10 @@ vm_name: rhel9-vm1
238216
----
239217
+
240218
. Re-run via the `Launch Template` button.
241-
219+
+
242220
image::stop_vms_multiple.png[title='Stopping the VMs', link=self, window=blank]
221+
+
222+
. Heading to the OpenShift UI dashboard, you can verify the VMs are stopped within the Virtualization -> Virtual Machines section.
243223

244224
=== Start VM Task
245225

@@ -249,19 +229,9 @@ will be added to the tasks directory in a file named `start_vm.yml`.
249229

250230
The following steps will guide you in creating the `start_vm.yml` file.
251231

252-
. Inside your `vm_management` role directory, go to the `tasks` folder:
253-
+
254-
----
255-
$ cd collections/ansible_collections/redhatone/vm_management/roles/vm_management/tasks/
256-
----
257-
+
258-
. Create the `start_vm.yml` file
259-
+
260-
----
261-
$ touch start_vm.yml
262-
----
232+
. Within your VSCode editor, right click `tasks` of the `vm_management` collection and create a New File labeled `start_vm.yml`
263233
+
264-
. Open the `start_vm.yml` file with your favorite editor and add the following task:
234+
. Add the following content to the `start_vm.yml`
265235
+
266236
----
267237
---
@@ -292,7 +262,7 @@ $ touch start_vm.yml
292262

293263
To execute the `manage_vm_playbook.yml` within Ansible Automation Platform, create a Job Template as follows:
294264

295-
. Navigate to **Automation Execution → Templates**, click the **Create template** button, and choose **Create job template**.
265+
. Head to the AAP UI dashboard, navigate to **Automation Execution → Templates**, click the **Create template** button, and choose **Create job template**.
296266
+
297267
. Fill out the following details:
298268
+
@@ -313,26 +283,18 @@ To execute the `manage_vm_playbook.yml` within Ansible Automation Platform, crea
313283
. Click **Create job template**.
314284
+
315285
. Once the `Start VMs` Job Template is created, select the **Launch Template** button on the top right corner to run the job.
286+
+
287+
. Head to the OpenShift UI dashboard, you can verify the VMs are running within the Virtualization -> Virtual Machines section.
316288

317289
=== Restart VM Task
318290

319291
In this lab exercise, you will focus on managing multiple VMs by creating a task to reboot your VMs. This task will be added to the `tasks` directory in a file named `restart_vm.yml`.
320292

321293
The following steps will guide you in creating the `restart_vm.yml` file.
322294

323-
. Inside your `vm_management` role directory, go to the `tasks` folder:
324-
+
325-
----
326-
$ cd collections/ansible_collections/redhatone/vm_management/roles/vm_management/tasks/
327-
----
328-
+
329-
. Create the `restart_vm.yml` file
330-
+
331-
----
332-
$ touch restart_vm.yml
333-
----
295+
. Within your VSCode editor, right click `tasks` of the `vm_management` collection and create a New File labeled `restart_vm.yml`
334296
+
335-
. Open the `restart_vm.yml` file with your favorite editor and add the following task:
297+
. Add the following content to the `restart_vm.yml`
336298
+
337299
----
338300
---
@@ -380,7 +342,7 @@ $ touch restart_vm.yml
380342

381343
To execute the `manage_vm_playbook.yml` within Ansible Automation Platform, create a Job Template as follows:
382344

383-
. Navigate to **Automation Execution → Templates**, click the **Create template** button, and choose **Create job template**.
345+
. Head to the AAP UI Dashboard, navigate to **Automation Execution → Templates**, click the **Create template** button, and choose **Create job template**.
384346
+
385347
. Fill out the following details:
386348
+
@@ -401,6 +363,7 @@ To execute the `manage_vm_playbook.yml` within Ansible Automation Platform, crea
401363
. Click **Create job template**.
402364
+
403365
. Once the `Restart VMs` Job Template is created, select the **Launch Template** button on the top right corner to run the job.
366+
. Head to the OpenShift UI Dashboard to view the changes of the VMs.
404367

405368
== Conclusion
406369

@@ -416,7 +379,7 @@ By the end of this lab, you should now understand:
416379

417380
* How to dynamically retrieve and process VM information using the `ansible.builtin.debug` module
418381
* How to modify a collection and role for starting, stopping, and restarting VMs.
419-
* How to integrate the `redhatone.vm_managemenet` collection into an Ansible playbook and run it using the Ansible Automation Platform.
382+
* How to integrate the `redhatone.vm_management` collection into an Ansible playbook and run it using the Ansible Automation Platform.
420383

421384
These foundational skills set the stage for further automation, enabling you to
422385
automate new tasks and optimize resource usage in your environment. In

0 commit comments

Comments
 (0)