Ansible AWX Projects¶
In Ansible AWX, a "Project" represents the bridge between the AWX interface and the actual Ansible playbooks and roles used to automate tasks. Projects serve as the central repository for managing and organizing your automation content.
- Source Control Management - This could be a Git, Mercurial, or Subversion repository, among others, but nearly always Git.
- Playbooks - any accessible the source of your repository is where your Ansible content resides.
- Inventory - within a project, specific playbooks can be tied to specific inventories.
Adding a Public Project¶
Projects are accessible from Resources -> Projects. From here we can navigate to all of our projects or add new ones. Let's review the options for each of the projects:
- Name - The name of the project you would like to call it
- Description - Longer description of the project.
- Organization - A project must have at least one organization. Pick one organization now to create the project, and then after the project is created you can add additional organizations.
- SCM Type - Drop down of source control types, generally Git is used.
- Clean - Removes any local modifications prior to performing an update.
- Delete on Update - Deletes the local repository in its entirety prior to performing an update.
- Update Revision on Launch - Updates the revision of the project to the current revision in the remote source control, as well as cache the roles directory from Galaxy or Collections.
Let's review via a quick demo how the projects are added.
Adding a Public Project - Lab¶
Let's setup a few different projects, based on the same repo. We will explore some of the options and common patterns you can use with a given repo.
- Add a project called -
test-playbooks [main]- Git URL: https://github.com/ansible/test-playbooks
- Branch: main
- Add a project called -
test-playbooks [dev]- Git URL: https://github.com/ansible/test-playbooks
- Branch: dev
- Branch: dev
- Add a project called -
test-playbooks [options]- Git URL: https://github.com/ansible/test-playbooks
- Branch: dev
- Clean: True
- Delete: True
- Update Revision on Launch: True
Rerun the job on multiple projects, from a specific project view as well as the list view.
- How many tasks are ran on each?
- What is the last commit ID on each?
Adding a Private Project¶
The process is generally speaking the same, except for you have to handle credentials. In this short overview, we are going to:
- Generate an SSH Key
- Add the public key to our GitHub Repo
- Create a new SSH key project
- Add our private key to the local instance
Step 1. Generate you ssh key. Let's create one just for the ntcu repo. We can save it to /root/.ssh/ntcu_id_rsa:
root@a0b5c75551a0:/tmp# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): /root/.ssh/ntcu_id_rsa
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/ntcu_id_rsa
Your public key has been saved in /root/.ssh/ntcu_id_rsa.pub
The key fingerprint is:
SHA256:jh3f6RI+JOZ2LcUKgtoi7Oyk15VYBoj+fughfeFJuHQ root@a0b5c75551a0
The key's randomart image is:
+---[RSA 3072]----+
| . . |
|. . . |
|. . |
| . . o |
| .o E .S . |
| o.B *++oo.o. |
|.o.B.=.+o=.=o |
|=.=o=. o B.. |
|+*.o. . . +. |
+----[SHA256]-----+
root@a0b5c75551a0:/tmp#
Step 2. Let's retrieve our ssh key from our local instance, via cat ~/.ssh/ntcu_id_rsa.pub
root@a0b5c75551a0:/tmp# cat ~/.ssh/ntcu_id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCnSZgYNsyjnnYaD9LHPRxprLv0F23cGX8NdZaM8QveEy+olK2aqvJIgpNhe9r155lsuQBn0cmAAbwrGcjTWiZNMtDQhoDwQnyDGYvP/xcoAx95zIDzqkG40CTz4JSpnI4+N96Ddp9SV4mtAAuY2FkCZTMzIz4DVQjQQPncX7vFwAvM7R1IPtnFGpqwxyTjW8R2ZrBALFt7VgjPG0WZiOylnwH+268t9K/MiktX4jOadBRZKPYSiSiPQeZ3ZMZU5HB0lJ/bNwAYu21N/jZoF9Gos4CkOPqb9+tlep05dv9NEZqyhivC1ULbz78efwNtowo90j22W/r+LHEaGzj9MMq751yxevkM8j36rZ1+KiPV7XBCYLb/RH1oRBarHHHOVNfQtmQ4d+ZH9BvMYFYs0/85qcz9sM8YOa57m6F2H5demTatPcW/Y0yzwFemNOXtmkbNlLMowMhnhPhhkPbMjwtRscrLnRaHJEafVp6lHV8n6qM5n5Er1JRsv2Ye6P17Las= root@a0b5c75551a0
root@a0b5c75551a0:/tmp#
Step 3. Let's add that Key to our GitHub Repo. Navigate to https://github.com/networktocode-llc/ntcu-class-2023
Step 4. From there Navigate to Settings -> Deploy Keys -> Add Deploy Keys
Step 5. In the Title add {initals} Deploy Key, in the key, provided in the cat ~/.ssh/ntcu_id_rsa.pub command, and click Add Key.
Step 6. From your host, let's grab the private key, via cat ~/.ssh/ntcu_id_rsa
root@a0b5c75551a0:/tmp# cat ~/.ssh/ntcu_id_rsa
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn
NhAAAAAwEAAQAAAYEAp0mYGDbMo552Gg/Sxz0caay79Bdt3Bl/DXWWjPEL3hMvqJStmqry
SIKTYXva9eeZbLkAZ9HJgAG8KxnI01omTTLQ0IaA8EJ8gxmLz/8XKAMfecyA86pBuNAk8+
CUqZyOPjfeg3afUleJrQALmNhZAmUzMyM+A1UI0ED53F+7xcALzO0dSD7ZxRqasMck41vE
dmawQCxbe1YIzxtFmYjspZ8B/tuvLfSvzIpLV+IzmnQUWSj2Eokoj0Hmd2TGVORwdJSf2z
cAGLttTf42aBfRqLOApDj6m/frZXqdOXb/TRGasoYrwtVC28+/Hn8DbaMKPdI9tlv6/ixx
Ghs4/TDKu+dcsXr5DPI9+q2dfioj1e1wQmC2/0R9aEQWqxxxzlTX0LZkOHfmR/QbzGBWLN
P/OanM/bDPGDmue5uhdh+XXpk2rT3Fv2NMs8BXpjTl7ZpGzZSzKMDIZ4T4YZD2zI8LUbHK
y50WhyRGn1aepR1fJ+qjOZ+RK9SUbL9mHuj9ey2rAAAFiCDS0Ywg0tGMAAAAB3NzaC1yc2
EAAAGBAKdJmBg2zKOedhoP0sc9HGmsu/QXbdwZfw11lozxC94TL6iUrZqq8kiCk2F72vXn
mWy5AGfRyYABvCsZyNNaJk0y0NCGgPBCfIMZi8//FygDH3nMgPOqQbjQJPPglKmcjj433o
N2n1JXia0AC5jYWQJlMzMjPgNVCNBA+dxfu8XAC8ztHUg+2cUamrDHJONbxHZmsEAsW3tW
CM8bRZmI7KWfAf7bry30r8yKS1fiM5p0FFko9hKJKI9B5ndkxlTkcHSUn9s3ABi7bU3+Nm
gX0aizgKQ4+pv362V6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ETEHtVWWVdSxku6dg1Z4wJPNcs0oP+gJy
f54IF/dZD9fO6F4XjbewVeYpAp0BOyli00MAsy5yt/oFAhMGMR/m9CTjj10Tzu+x2lDL8Q
S96+vrkQB0wr7hJUi0Cy/y/zqFYxzThudQdB/G67BPRait7lzn48jgOLGYV8UHWJ66YcBa
klJ95HCNFjCGd2Z5RIS2dSaA6kkWPy5QAAAMEAw/bsv9paHSb7UUhd0MFpXeOrcBhy453D
SE3kLIhfBSEoWtcsr8IRx5SFhHdkefZURNoWouJUvM5d0Iq+3fIi9dL+Mm7E+Avgp2s0zq
KKDduW6EWypP3oM/1Y/zUXHhMSJWIdQ0ezL+JhZAt+g0V23nS525XgCy1wGPpR8eGSTryP
vVVUYLtroBfgq5VxTNJbubivBefDrWCrinLG52LAkgFjrAbhR5rUv9gkzeHeG/4/JBqRAi
9u12nGDITmRcVPAAAAEXJvb3RAYTBiNWM3NTU1MWEwAQ==
-----END OPENSSH PRIVATE KEY-----
root@a0b5c75551a0:/tmp# cat ~/.ssh/ntcu_id_rsa
Step 7. Within your Ansible AWX instance, let's create a Credential with our private key. Navigate to Resources -> Credentials -> Add
- Add a credential called -
{initials} deploy key- Credential Type: Source Control
- SCM Private Key: Obtain details from
cat ~/.ssh/ntcu_id_rsa
Step 8. Within your Ansible AWX instance, let's create a project, Navigate to Resources -> Projects -> Add
- Add a project called -
ntcu [ssh]- Git URL: git@github.com:networktocode-llc/ntcu-class-2023.git
- Branch: develop
- Source Control Credential:
{initials} deploy key
Adding a Private Project - Lab¶
Follow the demo instructions for your own labs.