Skip to content

Commit

Permalink
Merge pull request #46 from bgraef/main
Browse files Browse the repository at this point in the history
add olam-builder code
  • Loading branch information
bgraef authored Jan 6, 2025
2 parents 4e23b88 + 17e5d68 commit 0316d3a
Show file tree
Hide file tree
Showing 3 changed files with 165 additions and 10 deletions.
19 changes: 14 additions & 5 deletions olam/deploy_olam_single.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
# Copyright (c) 2024 Oracle and/or its affiliates.
# Copyright (c) 2024, 2025 Oracle and/or its affiliates.
# This software is made available to you under the terms of the Universal Permissive License (UPL), Version 1.0.
# The Universal Permissive License (UPL), Version 1.0 (see COPYING or https://oss.oracle.com/licenses/upl)
# See LICENSE.TXT for details.
Expand All @@ -8,14 +8,16 @@
ansible.builtin.dnf:
name: oracle-epel-release-el8
state: present
when:
- ansible_facts['distribution_major_version'] == '8'
when: ansible_distribution == 'OracleLinux' and ansible_distribution_major_version == '8'
# when:
# - ansible_facts['distribution_major_version'] == '8'

- name: Install version lock plugin
ansible.builtin.dnf:
name: python3-dnf-plugin-versionlock
enablerepo: ol8_developer_EPEL
state: present
when: ansible_distribution == 'OracleLinux' and ansible_distribution_major_version == '8'

- name: Version lock python3-click
community.general.yum_versionlock:
Expand All @@ -30,6 +32,7 @@
- python3-pip
enablerepo: ol8_developer_EPEL
state: present
when: ansible_distribution == 'OracleLinux' and ansible_distribution_major_version == '8'

- name: Install pexpect using pip
ansible.builtin.pip:
Expand All @@ -47,8 +50,9 @@
profiles=
state=enabled
mode: '0644'
when:
- ansible_distribution_major_version | int >= 8
when: ansible_distribution == 'OracleLinux' and ansible_distribution_major_version == '8'
# when:
# - ansible_distribution_major_version | int >= 8

- name: Install the database
ansible.builtin.dnf:
Expand Down Expand Up @@ -127,6 +131,7 @@
ansible.builtin.dnf:
name: oraclelinux-automation-manager-release-el8
state: present
when: ansible_distribution == 'OracleLinux' and ansible_distribution_major_version == '8'

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

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

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

- name: Install Oracle Linux Automation Manager
ansible.builtin.dnf:
name: ol-automation-manager
state: present
when: ansible_distribution == 'OracleLinux' and ansible_distribution_major_version == '8'

- name: Edit unixsocket in /etc/redis.conf
ansible.builtin.lineinfile:
Expand Down
10 changes: 5 additions & 5 deletions olam/olam_passwordless_setup.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
# Copyright (c) 2024 Oracle and/or its affiliates.
# Copyright (c) 2024, 2025 Oracle and/or its affiliates.
# This software is made available to you under the terms of the Universal Permissive License (UPL), Version 1.0.
# The Universal Permissive License (UPL), Version 1.0 (see COPYING or https://oss.oracle.com/licenses/upl)
# See LICENSE.TXT for details.
Expand All @@ -11,7 +11,7 @@
comment: olam ssh keypair
become: true
become_user: "{{ username }}"
when: inventory_hostname in groups['control']
when: inventory_hostname in groups['control']|default([])

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

- name: Copy public key to ol-host
ansible.posix.authorized_key:
Expand All @@ -31,7 +31,7 @@
become: true
when:
- "'remote' in groups"
- inventory_hostname in groups['remote']
- inventory_hostname in groups['remote']|default([])

- name: Print hostvars for groups
ansible.builtin.debug:
Expand All @@ -53,4 +53,4 @@
changed_when: result.rc == 0
when:
- "'remote' in groups"
- inventory_hostname in groups['control']
- inventory_hostname in groups['control']|default([])
146 changes: 146 additions & 0 deletions olam/provision_builder.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
---
# Copyright (c) 2025 Oracle and/or its affiliates.
# This software is made available to you under the terms of the Universal Permissive License (UPL), Version 1.0.
# The Universal Permissive License (UPL), Version 1.0 (see COPYING or https://oss.oracle.com/licenses/upl)
# See LICENSE.TXT for details.

- name: Configure ansible control node
hosts: devops-node
become: true

vars:
debug_enabled: false

tasks:

- name: Install Oracle Linux Automation Manager repository
ansible.builtin.dnf:
name: oraclelinux-automation-manager-release-el8
state: present
when: ansible_distribution == 'OracleLinux' and ansible_distribution_major_version == '8'

- name: Disable Oracle Linux Automation Manager 1.0 repository
community.general.ini_file:
path: "/etc/yum.repos.d/oraclelinux-automation-manager-ol8.repo"
section: ol8_automation
option: enabled
value: "0"
mode: '0644'
when: ansible_distribution == 'OracleLinux' and ansible_distribution_major_version == '8'

- name: Disable Oracle Linux Automation Manager 2.0 repository
community.general.ini_file:
path: "/etc/yum.repos.d/oraclelinux-automation-manager-ol8.repo"
section: ol8_automation2
option: enabled
value: "0"
mode: '0644'
when: ansible_distribution == 'OracleLinux' and ansible_distribution_major_version == '8'

- name: Enable Oracle Linux Automation Manager 2.2 repository
community.general.ini_file:
path: "/etc/yum.repos.d/oraclelinux-automation-manager-ol8.repo"
section: ol8_automation2.2
option: enabled
value: "1"
mode: '0644'
when: ansible_distribution == 'OracleLinux' and ansible_distribution_major_version == '8'

- name: Install Oracle Linux Automation Manager Builder Utility
ansible.builtin.dnf:
name: python39-ansible-builder
state: present
when: ansible_distribution == 'OracleLinux' and ansible_distribution_major_version == '8'

- name: Install Ansible Runner using pip
ansible.builtin.pip:
name: ansible-runner
executable: pip3.9

- name: Create project directory
ansible.builtin.file:
path: ~/my_custom_ee_project
state: directory
mode: '0775'
become: true
become_user: "{{ username }}"

- name: Create execution-environment.yml
ansible.builtin.template:
src: templates/execution-environment.yml.j2
dest: ~/my_custom_ee_project/execution-environment.yml
mode: '0644'
become: true
become_user: "{{ username }}"

- name: Create ansible.cfg
ansible.builtin.template:
src: templates/ansible.cfg.j2
dest: ~/my_custom_ee_project/ansible.cfg
mode: '0644'
become: true
become_user: "{{ username }}"

- name: Create requirements.yml
ansible.builtin.template:
src: templates/requirements.yml.j2
dest: ~/my_custom_ee_project/requirements.yml
mode: '0644'
become: true
become_user: "{{ username }}"

- name: Create requirements.txt
ansible.builtin.template:
src: templates/requirements.txt.j2
dest: ~/my_custom_ee_project/requirements.txt
mode: '0644'
become: true
become_user: "{{ username }}"

- name: Create bomdep.txt
ansible.builtin.template:
src: templates/bindep.txt.j2
dest: ~/my_custom_ee_project/bindep.txt
mode: '0644'
become: true
become_user: "{{ username }}"

- name: Create custom execution environment image
ansible.builtin.shell: |
cd ~/my_custom_ee_project
ansible-builder build --tag my_custom_ee -v 3
become: true
become_user: "{{ username }}"
register: builder_output
changed_when: builder_output.rc != 0

- name: Print the Builder results
ansible.builtin.debug:
msg: "{{ builder_output.stdout }}"
when: debug_enabled

- name: Create runner private_data_dir
ansible.builtin.file:
path: /tmp/private/project
state: directory
mode: '0775'
become: true
become_user: "{{ username }}"

- name: Create playbook
ansible.builtin.template:
src: templates/playbook.yml.j2
dest: /tmp/private/project/playbook.yml
mode: '0644'
become: true
become_user: "{{ username }}"

# - name: Test custom ee
# ansible.builtin.command: ansible-runner run --process-isolation --container-image=my_custom_ee -p playbook.yml /tmp/private
# become_user: "{{ username }}"
# register: runner_output

# - name: Print runner results
# ansible.builtin.debug:
# msg: "{{ runner_output.stdout }}"
# when: debug_enabled

0 comments on commit 0316d3a

Please sign in to comment.