Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions olam/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,40 @@
ansible_host: "{{ instance_public_ip }}"
ansible_port: 22
instance_ocid: "{{ instance_id }}"

- name: Create host ini file
ansible.builtin.lineinfile:
path: hosts
regexp: '^\[{{ host_group }}'
line: "[{{ host_group }}]"
create: true
mode: "0664"
delegate_to: localhost
loop:
- control
- execution
- db
loop_control:
loop_var: host_group

- name: Add host to ini host file
ansible.builtin.lineinfile:
path: hosts
regexp: '^{{ instance_name }}'
line: >-
{{ instance_name }}
ansible_host={{ instance_ansible_host }}
ansible_user={{ instance_ansible_user }}
ansible_private_key_file={{ instance_ansible_private_key_file }}
ansible_ssh_common_args={{ instance_ansible_ssh_common_args | quote }}
insertafter: '^\[{{ item.value.type }}\]$'
create: true
mode: "664"
delegate_to: localhost
vars:
instance_name: "{{ instance_display_name }}"
instance_ansible_user: opc
instance_ansible_private_key_file: "{{ lookup('env', 'HOME') + '/.ssh/' + private_key }}"
instance_ansible_ssh_common_args: "-o StrictHostKeyChecking=no"
instance_ansible_host: "{{ instance_public_ip }}"
instance_ansible_port: 22
68 changes: 68 additions & 0 deletions olam/convert_ansible_inventory.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/bash

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

# Check if input file is provided
if [ $# -ne 1 ]; then
echo "Usage: $0 <input_file>"
exit 1
fi

# Set input file
input_file="$1"

# Check if input file exists
if [ ! -f "$input_file" ]; then
echo "Error: Input file '$input_file' does not exist."
exit 1
fi

# Extract hosts and create new format
echo "[control]"
grep "^olam-control-" "$input_file" | sed -E "s/ (ansible_user=opc|ansible_private_key_file=[^ ]+|ansible_ssh_common_args='[^']+')//g" | awk '{print $1, $2, $3}' | sort
echo ""

echo "[control:vars]"
echo "node_type=control"
echo "peers=local_execution_group"
echo ""

echo "[execution]"
grep -E "^olam-(execution|hop|remote-execution)-" "$input_file" | sed -E "s/ (ansible_user=opc|ansible_private_key_file=[^ ]+|ansible_ssh_common_args='[^']+')//g" | awk '{print $1, $2, $3}' | sort
echo ""

echo "[local_execution_group]"
grep "^olam-execution-" "$input_file" | sed -E "s/ (ansible_user=opc|ansible_private_key_file=[^ ]+|ansible_ssh_common_args='[^']+')//g" | awk '{print $1, $2, $3}' | sort
echo ""

echo "[local_execution_group:vars]"
echo "node_type=execution"
echo ""

echo "[hop]"
grep "^olam-hop-" "$input_file" | sed -E "s/ (ansible_user=opc|ansible_private_key_file=[^ ]+|ansible_ssh_common_args='[^']+')//g" | awk '{print $1, $2, $3}'
echo ""

echo "[hop:vars]"
echo "peers=control"
echo ""

echo "[remote_execution_group]"
grep "^olam-remote-execution-" "$input_file" | sed -E "s/ (ansible_user=opc|ansible_private_key_file=[^ ]+|ansible_ssh_common_args='[^']+')//g" | awk '{print $1, $2, $3}'
echo ""

echo "[remote_execution_group:vars]"
echo "peers=hop"
echo ""

echo "[db]"
grep "^olam-db" "$input_file" | sed -E "s/ (ansible_user=opc|ansible_private_key_file=[^ ]+|ansible_ssh_common_args='[^']+')//g" | awk '{print $1, $2, $3}'
echo ""

echo "[all:vars]"
echo "ansible_user=opc"
echo "ansible_private_key_file=/home/luna.user/.ssh/id_rsa"
echo "ansible_ssh_common_args='-o StrictHostKeyChecking=no'"
19 changes: 18 additions & 1 deletion olam/default_vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ instance_shape: "VM.Standard.E4.Flex"
instance_ocpus: 2
instance_memory: 32
subnet_cidr_block: "10.0.0.48/28"
private_key: "id_rsa"

username: "oracle"
usergroup: "{{ username }}"
Expand Down Expand Up @@ -43,4 +44,20 @@ vm_vcpus: 2
vm_ram_mb: 2048
vm_net: default
vm_root_pass:
cleanup_tmp: no
cleanup_tmp: no

awx_pguser_password: password
olam_admin_password: admin

# Set proxy if needed
# Uncomment both the pip_proxy_env and proxy_env sections, and set the proxy host and port accordingly.

pip_proxy_env:
# http_proxy: 'http://www.example.com:80
# https_proxy: 'https://www.example.com:80'

proxy_env:
# http_proxy: 'www.example.com:80'
# https_proxy: 'www.example.com:80'
# ftp_proxy: 'www.example.com:80'
# no_proxy: 'localhost,127.0.0.1,example.com'
Loading