Skip to content

Commit

Permalink
Merge branch 'devel' into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
IPvSean authored Oct 26, 2023
2 parents 99645b5 + 4c1bce0 commit ef7ee39
Show file tree
Hide file tree
Showing 60 changed files with 266 additions and 187 deletions.
2 changes: 2 additions & 0 deletions exercises/ansible_config_as_code/1-ee/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ ee_pull_collections_from_hub: false
{% endraw %}


=======

Further documentation for those who are interested to learn more see:

- [YAML lists and more](https://docs.ansible.com/ansible/latest/reference_appendices/YAMLSyntax.html)
Expand Down
31 changes: 18 additions & 13 deletions exercises/ansible_config_as_code/2-pah/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ In this section you will configure your private automation hub using the code pr

## Step 1

Ensure that you have `ansible-navigator` installed on your machine.

```console
sudo dnf install ansible-navigator
```
This lab uses `ansible-navigator` and has been tested against v3.4.1. It should be pre-installed on your machine.

Further documentation for those who are interested to learn more see:

Expand All @@ -22,12 +18,13 @@ Create a file `group_vars/all/ah_repositories.yml` you will need to add `infra.a
---
ah_collection_remotes:
- name: community-infra
url: https://beta-galaxy.ansible.com/
url: https://galaxy.ansible.com/
requirements:
- name: infra.ee_utilities
- name: infra.aap_utilities
- name: containers.podman
- name: awx.awx
- name: community.general

ah_collection_repositories:
- name: community-infra-repo
Expand All @@ -51,7 +48,7 @@ Further documentation for those who are interested to learn more see:

{% raw %}

Create a file `group_vars/all/ah_users.yml` make sure this user has `is_superuser` set to `true` and their `password` is set to `"{{ ah_token_password }}"`.
Create a file `group_vars/all/ah_users.yml` make sure this user has their `password` set to `"{{ ah_token_password }}"`.

```yaml
---
Expand All @@ -62,6 +59,7 @@ ah_users:
- "admin"
append: true
state: "present"
is_superuser: true
...

```
Expand All @@ -83,7 +81,7 @@ Further documentation for those who are interested to learn more see:

## Step 5

Create a playbook `playbooks/hub_config.yml` add in the `repository` role name in the first task and the `user` role name in the last task.
Create a playbook `playbooks/hub_config.yml` add in the `collection_remote` role name in the first task and the `user` role name in the last task.

```yaml
---
Expand All @@ -96,7 +94,7 @@ Create a playbook `playbooks/hub_config.yml` add in the `repository` role name i
tasks:
- name: Include collection remote role
ansible.builtin.include_role:
name: infra.ah_configuration. # Insert Collection Name here
name: infra.ah_configuration. # Insert Role Name here

- name: Include collection repository role
ansible.builtin.include_role:
Expand All @@ -112,17 +110,15 @@ Create a playbook `playbooks/hub_config.yml` add in the `repository` role name i

- name: Include user role
ansible.builtin.include_role:
name: infra.ah_configuration. # Insert Collection Name here
name: infra.ah_configuration. # Insert Role Name here
...
```

## Step 6

The next step is to run the playbook, for demonstration purposes we are going to show how to get the Execution Environment(EE) that was built in the previous step and run the playbook.

If you wish to skip this step run the playbook this way[^1].

[^1]: `ansible-galaxy collection install infra.ah_configuration` then `ansible-playbook -i inventory.yml -l automationhub playbooks/hub_config.yml`
If you wish to skip this step and use the CLI instead of navigator, see the alternate instructions in the next section.

Login to the automation hub using the podman login command. This will ask for a user:pass. After authenticating pull the config_as_code image.

Expand Down Expand Up @@ -151,4 +147,13 @@ Use these options to run the playbook in the execution environment.
ansible-navigator run playbooks/hub_config.yml --eei hub-student#.rh####.example.opentlc.com/config_as_code -i inventory.yml -l automationhub --pa='--tls-verify=false' -m stdout
```

## Step 6 (Alternate)
If someone was wrong with your execution environment, or want to run this in the CLI instead of Navigator, use the following commands.

```console
ansible-galaxy collection install infra.ah_configuration:2.0.3
ansible-playbook -i inventory.yml -l automationhub playbooks/hub_config.yml
```


[previous task](../1-ee/README.md) [next task](../3-controller/README.md)
20 changes: 11 additions & 9 deletions exercises/ansible_config_as_code/3-controller/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ controller_execution_environments:
![execution_environments supported](images/ee_supportedv3.png)
![execution_environments minimal](images/ee_minimalv2.png)
![execution_environments 2.9](images/ee_29v2.png)
![execution_environments 2.9](images/ee_config_as_code.png)

Further documentation for those who are interested to learn more see:

Expand Down Expand Up @@ -83,15 +84,15 @@ controller_credential_types:
env:
AH_PASSWORD: !unsafe "{{ password }}"
AH_USERNAME: !unsafe "{{ username }}"
AH_HOST: # Insert appropriate variable from above here
AH_HOST: !unsafe # Insert appropriate variable from above here
AH_API_TOKEN: !unsafe # Insert appropriate variable from above here
AH_VERIFY_SSL: !unsafe # Insert appropriate variable from above here
extra_vars:
ah_password: !unsafe "{{ password }}"
ah_username: !unsafe "{{ username }}"
ah_host: # Insert appropriate variable from above here
ah_token: # Insert appropriate variable from above here
ah_validate_certs: # Insert appropriate variable from above here
ah_host: !unsafe # Insert appropriate variable from above here
ah_token: !unsafe # Insert appropriate variable from above here
ah_validate_certs: !unsafe # Insert appropriate variable from above here

- name: ssh_priv_file
kind: cloud
Expand Down Expand Up @@ -138,7 +139,7 @@ Further documentation for those who are interested to learn more see:

## Step 5

Create a file `group_vars/all/credentials.yml` and add the required information to the list `controller_credentials` to configure the UI to look like the screenshot
Create a file `group_vars/all/credentials.yml` and add the required information to the list `controller_credentials` to configure the UI to look like the screenshot. Make it to look like the screenshot, but make sure to use parameters for the values. DO NOT PASTE YOUR CLEARTEST CREDENTIALS!

{% raw %}

Expand Down Expand Up @@ -203,7 +204,7 @@ controller_credentials:
username: student
password: "{{ machine_pass }}"

- name: git
- name: github
credential_type: Source Control
organization: config_as_code
description: git
Expand Down Expand Up @@ -276,7 +277,7 @@ controller_inventory_sources:
...
```

![inventory_source](images/inventory_source.png)
![inventory_source](images/inventory_source_v2.png)

Further documentation for those who are interested to learn more see:

Expand Down Expand Up @@ -454,10 +455,11 @@ Create a `collections/requirements.yml` file and add these collections to pull a
---
collections:
- name: infra.controller_configuration
version: 2.5.1
- name: infra.ah_configuration
- name: infra.ee_utilities
- name: infra.aap_utilities
version: 2.0.3
- name: awx.awx
version: 22.4.0
...
```

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
ah_collection_remotes:
- name: community-infra
url: https://beta-galaxy.ansible.com/
url: https://galaxy.ansible.com/
requirements:
- name: infra.ee_utilities
- name: infra.controller_configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ controller_credentials:
username: student
password: "{{ machine_pass }}"

- name: git
- name: github
credential_type: Source Control
organization: config_as_code
description: git
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@ controller_execution_environments:
image: "{{ ah_host }}/ee-29-rhel8"
pull: always
credential: cr_ah

- name: "config_as_code"
image: "{{ ah_host }}/config_as_code"
pull: always
credential: cr_ah
...
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
tasks:
- name: Include collection remote role
ansible.builtin.include_role:
name: infra.ah_configuration. # Insert Collection Name here
name: infra.ah_configuration.collection_remote

- name: Include collection repository role
ansible.builtin.include_role:
Expand All @@ -24,5 +24,5 @@

- name: Include user role
ansible.builtin.include_role:
name: infra.ah_configuration. # Insert Collection Name here
name: infra.ah_configuration.user
...
4 changes: 2 additions & 2 deletions roles/aws_dns/tasks/teardown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
record: "student{{item}}.{{ec2_name_prefix|lower}}.{{workshop_dns_zone}}"
type: A
value: "{{ (records | first | first)['Value'] }}"
loop: "{{ range(1, student_total + 1)|list }}"
loop: "{{ range(1, student_total|int + 1)|list }}"
vars:
records: '{{ record_sets.ResourceRecordSets | selectattr("Name", "match", "student" + item|string + "." + ec2_name_prefix|lower + "." + workshop_dns_zone) | map(attribute="ResourceRecords") | list }}'
when: records | length > 0
Expand All @@ -41,7 +41,7 @@
record: "student{{item}}-sat.{{ec2_name_prefix|lower}}.{{workshop_dns_zone}}"
type: A
value: "{{ (records | first | first)['Value'] }}"
loop: "{{ range(1, student_total + 1)|list }}"
loop: "{{ range(1, student_total|int + 1)|list }}"
vars:
records: '{{record_sets_sat.ResourceRecordSets | selectattr("Name", "match", "student" + item|string + "-sat." + ec2_name_prefix|lower + "." + workshop_dns_zone) | map(attribute="ResourceRecords") | list }}'
when: records | length > 0
Expand Down
39 changes: 39 additions & 0 deletions roles/control_node/templates/controller_eda_install.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[automationcontroller]
{{ ansible_default_ipv4.address }} ansible_connection=local

[automationedacontroller]
{{ ansible_default_ipv4.address }} ansible_connection=local

[database]
{{ ansible_default_ipv4.address }} ansible_connection=local


[all:vars]
admin_password='{{ admin_password }}'
automationcontroller_client_max_body_size='20M'

pg_host='{{ ansible_default_ipv4.address }}'
pg_port='5432'

pg_database='awx'
pg_username='awx'
pg_password='{{ admin_password }}'
pg_sslmode='prefer'

gpgcheck='{{ gpgcheck | default(1) }}'
aw_repo_url='{{ aw_repo_url | default("https://releases.ansible.com/ansible-tower/") }}'
ignore_preflight_errors = True

registry_url='{{ ee_registry_name }}'
registry_username='{{ redhat_username }}'
registry_password='{{ redhat_password }}'

controller_hostname='controller.replaceme.example.com'
automationedacontroller_hostname='eda.replaceme.example.com'

automationedacontroller_admin_password='{{ admin_password }}'
automationedacontroller_pg_host='{{ ansible_default_ipv4.address }}'
automationedacontroller_pg_port=5432
automationedacontroller_pg_database='automationedacontroller'
automationedacontroller_pg_username='automationedacontroller'
automationedacontroller_pg_password='{{ admin_password }}'
4 changes: 2 additions & 2 deletions roles/gitlab_server/tasks/add-users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
"skip_confirmation": true
}
register: create_user
with_sequence: count="{{ student_total }}"
with_sequence: count="{{ student_total|int }}"

- name: GitLab Post | Get local user information via API
uri:
Expand All @@ -138,5 +138,5 @@
headers:
Content-Type: application/json
Authorization: Bearer {{ gitlab_access_token.json.access_token }}
with_sequence: count="{{ student_total }}"
with_sequence: count="{{ student_total|int }}"
register: gitlab_local_users
2 changes: 1 addition & 1 deletion roles/gitlab_server/tasks/gitea-add-users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
--password """{{ admin_password }}"""
--email student{{ item }}@example.com
--must-change-password=false
with_sequence: count="{{ student_total }}"
with_sequence: count="{{ student_total|int }}"
become_user: gitea
register: gitearesult
failed_when:
Expand Down
2 changes: 1 addition & 1 deletion roles/manage_ec2_instances/tasks/cockpit_machines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
template:
src: "cockpit_machines/cockpit_machines_{{workshop_type}}.j2"
dest: "{{ playbook_dir }}/{{ec2_name_prefix}}/student{{item}}-99-webui.json"
with_sequence: count="{{ student_total }}"
with_sequence: count="{{ student_total|int }}"
4 changes: 2 additions & 2 deletions roles/manage_ec2_instances/tasks/create_inventory.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
template:
src: "student_inventory/instances_{{workshop_type}}.j2"
dest: "{{ playbook_dir }}/{{ec2_name_prefix}}/student{{item}}-instances.txt"
with_sequence: count="{{ student_total }}"
with_sequence: count="{{ student_total|int }}"

- name: Generate student etchosts
template:
src: "etchosts/etchosts_{{workshop_type}}.j2"
dest: "{{ playbook_dir }}/{{ec2_name_prefix}}/student{{item}}-etchosts.txt"
with_sequence: count="{{ student_total }}"
with_sequence: count="{{ student_total|int }}"

- name: Generate instructor inventory
template:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
owner: "{{ aws_user }}"
Info: "Username that provisioned this-> {{ aws_user }}"
Linklight: "This was provisioned through the linklight provisioner"
Students: "{{ student_total }}"
Students: "{{ student_total|int }}"
short_name: 'attendance-host'
long_name: "attendance-host.{{ ec2_name_prefix }}.{{ workshop_dns_zone | default('') }}"
username: "{{ ec2_info['attendance_host']['username'] }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
instance_type: "{{ ec2_info['satellite'].size[list_count|int] }}"
image_id: "{{ sat_ami.image_id }}"
region: "{{ ec2_region }}"
exact_count: "{{ student_total }}"
exact_count: "{{ student_total|int }}"
state: running
filters:
instance-state-name: running
Expand All @@ -23,7 +23,7 @@
owner: "{{ aws_user }}"
Info: "AWS_USERNAME that provisioned this-> {{ aws_user }}"
Ansible_Workshops: "This was provisioned through the ansible workshops provisioner"
Students: "{{ student_total }}"
Students: "{{ student_total|int }}"
short_name: "satellite"
username: "{{ ec2_info[rhel].username }}"
ansible-workshops: "true"
Expand Down
Loading

0 comments on commit ef7ee39

Please sign in to comment.