Skip to content

Commit b4c2b88

Browse files
author
Jakub Veverka
committed
Configure Ansible Tower to use execution Container Group
mainly documentaiton of how to set OpenShift and Tower. Custom container image had to be used because there gcp modules don't run on default Ansible Tower instance group.
1 parent 963dad5 commit b4c2b88

File tree

5 files changed

+81
-3
lines changed

5 files changed

+81
-3
lines changed

GCP_VM_Delete.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
gather_facts: no
66
vars:
77
gcp_project: ceenter
8-
scopes:
9-
- https://www.googleapis.com/auth/compute
108
zone: "europe-west3-a"
119
region: "europe-west3"
1210

@@ -17,3 +15,9 @@
1715
name: "{{ vm_name | default('ansible-tower-test', true) }}"
1816
zone: "{{ zone }}"
1917
project: "{{ gcp_project }}"
18+
- name: delete an address
19+
gcp_compute_address:
20+
name: "{{ vm_address_name | default('ansible-tower-test-address', true) }}"
21+
region: "{{ region }}"
22+
project: "{{ gcp_project }}"
23+
state: absent

README.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ Download [GCP credentials](https://docs.ansible.com/ansible/latest/scenario_guid
5151
ansible-playbook GCP_VM_Create.yml
5252
```
5353

54-
## Ansible Tower Setup
54+
## Ansible Tower
55+
56+
### Tower setup
5557

5658
Create Credential:
5759
- GCP connection
@@ -68,3 +70,32 @@ Create Job Templates:
6870
Authenticate Ansible Tower to Automation-hub:
6971
- Retrieve token at https://cloud.redhat.com/ansible/automation-hub/token
7072
- Update token in Ansible Tower: https://www.ansible.com/blog/installing-and-using-collections-on-ansible-tower
73+
74+
### OpenShift setup
75+
76+
Additional Container Group on OpenShift
77+
- `oc create -n tower -f ocp-setup/role-pod-manager.yml`
78+
- `oc create -n tower -f ocp-setup/sa-tower-container-group.yml`
79+
- `oc create -n tower -f ocp-setup/rb-tower-container-group.yml`
80+
81+
Download serviceaccount credentials, e.g. from ui download serviceaccount kubeconfig.
82+
83+
Customize Pod Spec on Instance Group
84+
```yaml
85+
---
86+
apiVersion: v1
87+
kind: Pod
88+
metadata:
89+
namespace: tower
90+
spec:
91+
containers:
92+
- image: quay.io/ceenter/ansible-runner-google:1.4.6
93+
tty: true
94+
stdin: true
95+
imagePullPolicy: Always
96+
args:
97+
- sleep
98+
- infinity
99+
```
100+
101+
Container image is build in [ansible-runner-images repository](https://github.com/ceenter/ansible-runner-images).
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
kind: RoleBinding
3+
apiVersion: rbac.authorization.k8s.io/v1
4+
metadata:
5+
name: tower-container-group
6+
subjects:
7+
- kind: ServiceAccount
8+
name: tower-container-group
9+
namespace: tower
10+
roleRef:
11+
apiGroup: rbac.authorization.k8s.io
12+
kind: Role
13+
name: pod-manager

ocp-setup/role-pod-manager.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
# Role for managing Pods, presumably by Ansible Tower
3+
apiVersion: rbac.authorization.k8s.io/v1
4+
kind: Role
5+
metadata:
6+
name: pod-manager
7+
rules:
8+
- verbs:
9+
- get
10+
- list
11+
- watch
12+
- create
13+
- update
14+
- patch
15+
- delete
16+
apiGroups:
17+
- ''
18+
resources:
19+
- pods
20+
- verbs:
21+
- create
22+
apiGroups:
23+
- ''
24+
resources:
25+
- pods/exec
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: tower-container-group

0 commit comments

Comments
 (0)