1
+ #! /bin/bash
2
+
3
+ # Copyright (c) 2024, 2025 Oracle and/or its affiliates.
4
+ # This software is made available to you under the terms of the Universal Permissive License (UPL), Version 1.0.
5
+ # The Universal Permissive License (UPL), Version 1.0 (see COPYING or https://oss.oracle.com/licenses/upl)
6
+ # See LICENSE.TXT for details.
7
+
8
+ # Check if input file is provided
9
+ if [ $# -ne 1 ]; then
10
+ echo " Usage: $0 <input_file>"
11
+ exit 1
12
+ fi
13
+
14
+ # Set input file
15
+ input_file=" $1 "
16
+
17
+ # Check if input file exists
18
+ if [ ! -f " $input_file " ]; then
19
+ echo " Error: Input file '$input_file ' does not exist."
20
+ exit 1
21
+ fi
22
+
23
+ # Extract hosts and create new format
24
+ echo " [control]"
25
+ 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
26
+ echo " "
27
+
28
+ echo " [control:vars]"
29
+ echo " node_type=control"
30
+ echo " peers=local_execution_group"
31
+ echo " "
32
+
33
+ echo " [execution]"
34
+ 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
35
+ echo " "
36
+
37
+ echo " [local_execution_group]"
38
+ 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
39
+ echo " "
40
+
41
+ echo " [local_execution_group:vars]"
42
+ echo " node_type=execution"
43
+ echo " "
44
+
45
+ echo " [hop]"
46
+ 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}'
47
+ echo " "
48
+
49
+ echo " [hop:vars]"
50
+ echo " peers=control"
51
+ echo " "
52
+
53
+ echo " [remote_execution_group]"
54
+ 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}'
55
+ echo " "
56
+
57
+ echo " [remote_execution_group:vars]"
58
+ echo " peers=hop"
59
+ echo " "
60
+
61
+ echo " [db]"
62
+ 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}'
63
+ echo " "
64
+
65
+ echo " [all:vars]"
66
+ echo " ansible_user=opc"
67
+ echo " ansible_private_key_file=/home/luna.user/.ssh/id_rsa"
68
+ echo " ansible_ssh_common_args='-o StrictHostKeyChecking=no'"
0 commit comments