Skip to content

Commit 0316d3a

Browse files
authored
Merge pull request #46 from bgraef/main
add olam-builder code
2 parents 4e23b88 + 17e5d68 commit 0316d3a

File tree

3 files changed

+165
-10
lines changed

3 files changed

+165
-10
lines changed

olam/deploy_olam_single.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
# Copyright (c) 2024 Oracle and/or its affiliates.
2+
# Copyright (c) 2024, 2025 Oracle and/or its affiliates.
33
# This software is made available to you under the terms of the Universal Permissive License (UPL), Version 1.0.
44
# The Universal Permissive License (UPL), Version 1.0 (see COPYING or https://oss.oracle.com/licenses/upl)
55
# See LICENSE.TXT for details.
@@ -8,14 +8,16 @@
88
ansible.builtin.dnf:
99
name: oracle-epel-release-el8
1010
state: present
11-
when:
12-
- ansible_facts['distribution_major_version'] == '8'
11+
when: ansible_distribution == 'OracleLinux' and ansible_distribution_major_version == '8'
12+
# when:
13+
# - ansible_facts['distribution_major_version'] == '8'
1314

1415
- name: Install version lock plugin
1516
ansible.builtin.dnf:
1617
name: python3-dnf-plugin-versionlock
1718
enablerepo: ol8_developer_EPEL
1819
state: present
20+
when: ansible_distribution == 'OracleLinux' and ansible_distribution_major_version == '8'
1921

2022
- name: Version lock python3-click
2123
community.general.yum_versionlock:
@@ -30,6 +32,7 @@
3032
- python3-pip
3133
enablerepo: ol8_developer_EPEL
3234
state: present
35+
when: ansible_distribution == 'OracleLinux' and ansible_distribution_major_version == '8'
3336

3437
- name: Install pexpect using pip
3538
ansible.builtin.pip:
@@ -47,8 +50,9 @@
4750
profiles=
4851
state=enabled
4952
mode: '0644'
50-
when:
51-
- ansible_distribution_major_version | int >= 8
53+
when: ansible_distribution == 'OracleLinux' and ansible_distribution_major_version == '8'
54+
# when:
55+
# - ansible_distribution_major_version | int >= 8
5256

5357
- name: Install the database
5458
ansible.builtin.dnf:
@@ -127,6 +131,7 @@
127131
ansible.builtin.dnf:
128132
name: oraclelinux-automation-manager-release-el8
129133
state: present
134+
when: ansible_distribution == 'OracleLinux' and ansible_distribution_major_version == '8'
130135

131136
- name: Disable Oracle Linux Automation Manager 1.0 repository
132137
community.general.ini_file:
@@ -135,6 +140,7 @@
135140
option: enabled
136141
value: "0"
137142
mode: '0644'
143+
when: ansible_distribution == 'OracleLinux' and ansible_distribution_major_version == '8'
138144

139145
- name: Disable Oracle Linux Automation Manager 2.0 repository
140146
community.general.ini_file:
@@ -143,6 +149,7 @@
143149
option: enabled
144150
value: "0"
145151
mode: '0644'
152+
when: ansible_distribution == 'OracleLinux' and ansible_distribution_major_version == '8'
146153

147154
- name: Enable Oracle Linux Automation Manager 2.2 repository
148155
community.general.ini_file:
@@ -151,11 +158,13 @@
151158
option: enabled
152159
value: "1"
153160
mode: '0644'
161+
when: ansible_distribution == 'OracleLinux' and ansible_distribution_major_version == '8'
154162

155163
- name: Install Oracle Linux Automation Manager
156164
ansible.builtin.dnf:
157165
name: ol-automation-manager
158166
state: present
167+
when: ansible_distribution == 'OracleLinux' and ansible_distribution_major_version == '8'
159168

160169
- name: Edit unixsocket in /etc/redis.conf
161170
ansible.builtin.lineinfile:

olam/olam_passwordless_setup.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
# Copyright (c) 2024 Oracle and/or its affiliates.
2+
# Copyright (c) 2024, 2025 Oracle and/or its affiliates.
33
# This software is made available to you under the terms of the Universal Permissive License (UPL), Version 1.0.
44
# The Universal Permissive License (UPL), Version 1.0 (see COPYING or https://oss.oracle.com/licenses/upl)
55
# See LICENSE.TXT for details.
@@ -11,7 +11,7 @@
1111
comment: olam ssh keypair
1212
become: true
1313
become_user: "{{ username }}"
14-
when: inventory_hostname in groups['control']
14+
when: inventory_hostname in groups['control']|default([])
1515

1616
- name: Fetch public key file from ol-control-node
1717
ansible.builtin.fetch:
@@ -20,7 +20,7 @@
2020
flat: true
2121
become: true
2222
become_user: "{{ username }}"
23-
when: inventory_hostname in groups['control']
23+
when: inventory_hostname in groups['control']|default([])
2424

2525
- name: Copy public key to ol-host
2626
ansible.posix.authorized_key:
@@ -31,7 +31,7 @@
3131
become: true
3232
when:
3333
- "'remote' in groups"
34-
- inventory_hostname in groups['remote']
34+
- inventory_hostname in groups['remote']|default([])
3535

3636
- name: Print hostvars for groups
3737
ansible.builtin.debug:
@@ -53,4 +53,4 @@
5353
changed_when: result.rc == 0
5454
when:
5555
- "'remote' in groups"
56-
- inventory_hostname in groups['control']
56+
- inventory_hostname in groups['control']|default([])

olam/provision_builder.yml

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
---
2+
# Copyright (c) 2025 Oracle and/or its affiliates.
3+
# This software is made available to you under the terms of the Universal Permissive License (UPL), Version 1.0.
4+
# The Universal Permissive License (UPL), Version 1.0 (see COPYING or https://oss.oracle.com/licenses/upl)
5+
# See LICENSE.TXT for details.
6+
7+
- name: Configure ansible control node
8+
hosts: devops-node
9+
become: true
10+
11+
vars:
12+
debug_enabled: false
13+
14+
tasks:
15+
16+
- name: Install Oracle Linux Automation Manager repository
17+
ansible.builtin.dnf:
18+
name: oraclelinux-automation-manager-release-el8
19+
state: present
20+
when: ansible_distribution == 'OracleLinux' and ansible_distribution_major_version == '8'
21+
22+
- name: Disable Oracle Linux Automation Manager 1.0 repository
23+
community.general.ini_file:
24+
path: "/etc/yum.repos.d/oraclelinux-automation-manager-ol8.repo"
25+
section: ol8_automation
26+
option: enabled
27+
value: "0"
28+
mode: '0644'
29+
when: ansible_distribution == 'OracleLinux' and ansible_distribution_major_version == '8'
30+
31+
- name: Disable Oracle Linux Automation Manager 2.0 repository
32+
community.general.ini_file:
33+
path: "/etc/yum.repos.d/oraclelinux-automation-manager-ol8.repo"
34+
section: ol8_automation2
35+
option: enabled
36+
value: "0"
37+
mode: '0644'
38+
when: ansible_distribution == 'OracleLinux' and ansible_distribution_major_version == '8'
39+
40+
- name: Enable Oracle Linux Automation Manager 2.2 repository
41+
community.general.ini_file:
42+
path: "/etc/yum.repos.d/oraclelinux-automation-manager-ol8.repo"
43+
section: ol8_automation2.2
44+
option: enabled
45+
value: "1"
46+
mode: '0644'
47+
when: ansible_distribution == 'OracleLinux' and ansible_distribution_major_version == '8'
48+
49+
- name: Install Oracle Linux Automation Manager Builder Utility
50+
ansible.builtin.dnf:
51+
name: python39-ansible-builder
52+
state: present
53+
when: ansible_distribution == 'OracleLinux' and ansible_distribution_major_version == '8'
54+
55+
- name: Install Ansible Runner using pip
56+
ansible.builtin.pip:
57+
name: ansible-runner
58+
executable: pip3.9
59+
60+
- name: Create project directory
61+
ansible.builtin.file:
62+
path: ~/my_custom_ee_project
63+
state: directory
64+
mode: '0775'
65+
become: true
66+
become_user: "{{ username }}"
67+
68+
- name: Create execution-environment.yml
69+
ansible.builtin.template:
70+
src: templates/execution-environment.yml.j2
71+
dest: ~/my_custom_ee_project/execution-environment.yml
72+
mode: '0644'
73+
become: true
74+
become_user: "{{ username }}"
75+
76+
- name: Create ansible.cfg
77+
ansible.builtin.template:
78+
src: templates/ansible.cfg.j2
79+
dest: ~/my_custom_ee_project/ansible.cfg
80+
mode: '0644'
81+
become: true
82+
become_user: "{{ username }}"
83+
84+
- name: Create requirements.yml
85+
ansible.builtin.template:
86+
src: templates/requirements.yml.j2
87+
dest: ~/my_custom_ee_project/requirements.yml
88+
mode: '0644'
89+
become: true
90+
become_user: "{{ username }}"
91+
92+
- name: Create requirements.txt
93+
ansible.builtin.template:
94+
src: templates/requirements.txt.j2
95+
dest: ~/my_custom_ee_project/requirements.txt
96+
mode: '0644'
97+
become: true
98+
become_user: "{{ username }}"
99+
100+
- name: Create bomdep.txt
101+
ansible.builtin.template:
102+
src: templates/bindep.txt.j2
103+
dest: ~/my_custom_ee_project/bindep.txt
104+
mode: '0644'
105+
become: true
106+
become_user: "{{ username }}"
107+
108+
- name: Create custom execution environment image
109+
ansible.builtin.shell: |
110+
cd ~/my_custom_ee_project
111+
ansible-builder build --tag my_custom_ee -v 3
112+
become: true
113+
become_user: "{{ username }}"
114+
register: builder_output
115+
changed_when: builder_output.rc != 0
116+
117+
- name: Print the Builder results
118+
ansible.builtin.debug:
119+
msg: "{{ builder_output.stdout }}"
120+
when: debug_enabled
121+
122+
- name: Create runner private_data_dir
123+
ansible.builtin.file:
124+
path: /tmp/private/project
125+
state: directory
126+
mode: '0775'
127+
become: true
128+
become_user: "{{ username }}"
129+
130+
- name: Create playbook
131+
ansible.builtin.template:
132+
src: templates/playbook.yml.j2
133+
dest: /tmp/private/project/playbook.yml
134+
mode: '0644'
135+
become: true
136+
become_user: "{{ username }}"
137+
138+
# - name: Test custom ee
139+
# ansible.builtin.command: ansible-runner run --process-isolation --container-image=my_custom_ee -p playbook.yml /tmp/private
140+
# become_user: "{{ username }}"
141+
# register: runner_output
142+
143+
# - name: Print runner results
144+
# ansible.builtin.debug:
145+
# msg: "{{ runner_output.stdout }}"
146+
# when: debug_enabled

0 commit comments

Comments
 (0)