|
| 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