In this exercise, we’re going to write a simple playbook to template out our kickstart file, create a job template for it, run the job template, then review the generated kickstart file. Once complete, we should have a functional kickstart ready to use with our edge devices.
Return to the code repo via the method that you were editing files (VSCode, VIM, etc) previously, and create a new playbook in the playbooks/
directory of your repo called template-kickstart.yml
. We’ll only need one task for this playbook which will be used to render the kickstart file to a directory served by the web server.
Populate the template-kickstart.yml
file with the following content:
---
- name: template out kickstart file
hosts:
- all
become: true
tasks:
- name: push templated kickstart file
ansible.builtin.template:
src: templates/student{{ student_number }}.ks.j2
dest: "/var/www/html/student{{ student_number }}-kickstart.ks"
owner: apache
group: apache
mode: '0755'
A few notes about this playbook:
hosts: all
because we’ll use Ansible Controller to determine what inventories/hosts to targetinst.ks=
boot option. For more information on this process, refer to this Red Hat Knowledgebase Article.Once your playbook is constructed, push it up into your git repo.
Note
Be sure to sync your project in Controller before attempting to create this job template. To sync the project, navigate to Resources > Project and click on the sync icon for the only project available
Now that we have a playbook and template, we can build a job template to push our our kickstart file.
On the Resources > Templates page, select Add > Add job template and enter the following information:
Parameter | Value |
---|---|
Name | Template Out Kickstart |
Inventory | Edge Utilities |
Project | Device Edge Codebase |
Execution Environment | Device Edge Workshops Execution Environment |
Playbook | playbooks/template-kickstart.yml |
Credentials |
|
Limit | edge_manager |
Options |
|
Remember to click Save.
Note
If you’re not planning to kickstart over wifi, then the
Wireless Network Info
credential is not needed.
Now that the job template has been created, click on the Launch button to start a Job. Monitor the output for any errors or issues.
As a reminder, the output of jobs can be reviewed on the Jobs tab.
Once the job has completed, the kickstart file can be viewed immediately via connecting to the web server. Open a web browser and navigate to http://(edge-manager-from-your-student-page)/student$(your-student-number)-kickstart.ks
Ideally, the variables and conditional blocks will have templated properly, and the kickstart will be filled out with all the correct information. Review the contents of the kickstart to confirm the values you’re expecting are present.
Remember: a portion of the playbook was surrounded by the raw
key, meaning Ansible didn’t attempt to resolve/replace the variables and rendered the content as it was declared. This is by design, as our playbook has some of its own variables.
Template Kickstart job template:
Template Kickstart select credentials:
Navigation
Previous Exercise | Next Exercise |