Ubuntu 22.04
Sponsored Link

Ansible : AWX : Add Job Templates2022/09/27

 
This is the basic configuration for Ansible AWX to run Ansible Playbooks.
To run Playbooks on target Hosts on AWX, it needs to configure the following settings.
* Add inventories
* Add credentials
* Add projects
* Add job templates
To add job templates, configure like follows.
Before it, it needs to prepare Playbooks on Source Control repository you set on the project you added like here.
This example is based on the environment that Git repository is set with HTTP access enabled for the Source Control.
[1] Create a Playbook on Source Control repository that you'd like to execute on target Hosts from AWX.
If you set Git repository like this example, refer to follows as a way to create Playbooks.
# move to working directory

ubuntu@dlp:~$
cd ~/work/project01
# create a test Playbook

ubuntu@dlp:~/work/project01$
vi helloworld.yml
# create new
# for example, touch a file [/tmp/helloworld.txt] with 644 on target Hosts
# for [hosts] value, specify the group name you set on an inventory you added
# ⇒ example [hosts] value below, that is the group name set on here of [6]

---
- hosts: CentOS
  tasks:
  - name: Test Task
    file:
      path: /tmp/helloworld.txt
      state: touch
      owner: root
      group: root
      mode: 0644

# push to repository

ubuntu@dlp:~/work/project01$
git add helloworld.yml

ubuntu@dlp:~/work/project01$
git commit helloworld.yml -m "Initial Commit"

ubuntu@dlp:~/work/project01$
git remote -v

origin  http://ubuntu@dlp.srv.world/git/project01.git (fetch)
origin  http://ubuntu@dlp.srv.world/git/project01.git (push)
ubuntu@dlp:~/work/project01$
git push origin master

[2] When you create new Playbooks on the repository set as Source Control, it needs to sync them with AWX.
Login to Ansible AWX Web and click [Projects] on the left pane and open the project you added, and then, click [Sync] button to import new Playbooks.
[3] Add job templates, Click [Templates] on the left pane.
[4] Click [Add] - [Add job template] on the right pane.
[5]
Input basic information for job template and click [Save] button to save.
[Name] :   Set any name you like
[Job Type] :   Specify job type
[Run] or [Check] - if [Check] selected, only Playbook syntax is checked
[Inventory] :   Specify an inventory
To click magnifying glass icon, it's possible to select from the existing inventories you added
[Project] :   Specify projects
To click magnifying glass icon, it's possible to select from the existing projects you added
[Execution Environment] :   Specify Execution Environment when jobs are executed
To click magnifying glass icon, it's possible to select from the list below
[AWX EE (latest)], [Control Plane Execution Environment]
[Playbook] :   Specify a Playbook you'd like to execute
it's possible to select from the list of Playbooks that are stored on the Source Control repository specified on [Project]
[Credentials] :   Specify Credential for target Hosts
target Hosts means the Host/Group you set in the Playbook
To click magnifying glass icon, it's possible to select from the existing credentials you added
[Privilege Escalation] :   If you set common user in specified Credential, check a box to escalate to root privilege on target Host

[6] After Saving template, that's OK if following screen is shown.
[6] After adding a job template, That's OK if template is displayed on [Templates] list.
Matched Content