Skip to content

Commit 524117e

Browse files
author
Jakub Veverka
committed
configure ansible tower to use execution container group
1 parent 8741f9a commit 524117e

File tree

6 files changed

+115
-36
lines changed

6 files changed

+115
-36
lines changed

GCP_VM_Create.yml

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,36 @@
99
region: "europe-west3"
1010

1111
tasks:
12-
- name: create a disk
13-
gcp_compute_disk:
14-
name: "{{ vm_disk_name | default('ansible-tower-test-disk', true) }}"
15-
size_gb: 50
16-
source_image: 'projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts'
17-
zone: "{{ zone }}"
18-
project: "{{ gcp_project }}"
19-
state: present
20-
register: disk
21-
- name: create a address
22-
gcp_compute_address:
23-
name: "{{ vm_address_name | default('ansible-tower-test-address', true) }}"
24-
region: "{{ region }}"
25-
project: "{{ gcp_project }}"
26-
state: present
27-
register: address
28-
- name: create a instance
29-
gcp_compute_instance:
30-
state: present
31-
name: "{{ vm_name | default('ansible-tower-test', true) }}"
32-
machine_type: n1-standard-1
33-
disks:
34-
- auto_delete: true
35-
boot: true
36-
source: "{{ disk }}"
37-
network_interfaces:
38-
- network: null # use default
39-
access_configs:
40-
- name: 'External NAT'
41-
nat_ip: "{{ address }}"
42-
type: 'ONE_TO_ONE_NAT'
43-
zone: "{{ zone }}"
44-
project: "{{ gcp_project }}"
12+
- name: create a disk
13+
gcp_compute_disk:
14+
name: "{{ vm_disk_name | default('ansible-tower-test-disk', true) }}"
15+
size_gb: 50
16+
source_image: 'projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts'
17+
zone: "{{ zone }}"
18+
project: "{{ gcp_project }}"
19+
state: present
20+
register: disk
21+
- name: create a address
22+
gcp_compute_address:
23+
name: "{{ vm_address_name | default('ansible-tower-test-address', true) }}"
24+
region: "{{ region }}"
25+
project: "{{ gcp_project }}"
26+
state: present
27+
register: address
28+
- name: create a instance
29+
gcp_compute_instance:
30+
state: present
31+
name: "{{ vm_name | default('ansible-tower-test', true) }}"
32+
machine_type: n1-standard-1
33+
disks:
34+
- auto_delete: true
35+
boot: true
36+
source: "{{ disk }}"
37+
network_interfaces:
38+
- network: null # use default
39+
access_configs:
40+
- name: 'External NAT'
41+
nat_ip: "{{ address }}"
42+
type: 'ONE_TO_ONE_NAT'
43+
zone: "{{ zone }}"
44+
project: "{{ gcp_project }}"

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: 30 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,30 @@ 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 -f ocp-setup/role-pod-manager.yml`
78+
- `oc create -f ocp-setup/sa-tower-container-group.yml`
79+
- `oc create -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/jveverka/ansible-runner-google:1.4.6
93+
tty: true
94+
stdin: true
95+
imagePullPolicy: Always
96+
args:
97+
- sleep
98+
- infinity
99+
```
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
kind: RoleBinding
3+
apiVersion: rbac.authorization.k8s.io/v1
4+
metadata:
5+
name: tower-container-group
6+
namespace: tower
7+
subjects:
8+
- kind: ServiceAccount
9+
name: tower-container-group
10+
namespace: tower
11+
roleRef:
12+
apiGroup: rbac.authorization.k8s.io
13+
kind: Role
14+
name: pod-manager

ocp-setup/role-pod-manager.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
namespace: tower
8+
rules:
9+
- verbs:
10+
- get
11+
- list
12+
- watch
13+
- create
14+
- update
15+
- patch
16+
- delete
17+
apiGroups:
18+
- ''
19+
resources:
20+
- pods
21+
- verbs:
22+
- create
23+
apiGroups:
24+
- ''
25+
resources:
26+
- pods/exec
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: tower-container-group
6+
namespace: tower

0 commit comments

Comments
 (0)