From 8050d3f69a15258f8f92b8ed3706e5fb546e0f64 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 18 Mar 2021 14:30:18 -0400 Subject: [PATCH] Add playbook examples for default genesis --- .../default/ansible/onboot.d/README.txt | 25 +++++++++++++++++++ .../profiles/default/scripts/functions | 17 +++++++++++++ .../profiles/default/scripts/onboot.sh | 3 +++ 3 files changed, 45 insertions(+) create mode 100644 confluent_osdeploy/genesis/profiles/default/ansible/onboot.d/README.txt diff --git a/confluent_osdeploy/genesis/profiles/default/ansible/onboot.d/README.txt b/confluent_osdeploy/genesis/profiles/default/ansible/onboot.d/README.txt new file mode 100644 index 00000000..97e5f506 --- /dev/null +++ b/confluent_osdeploy/genesis/profiles/default/ansible/onboot.d/README.txt @@ -0,0 +1,25 @@ +Ansible playbooks ending in .yml or .yaml that are placed into this directory will be executed at the +appropriate phase of the install process. + +The 'hosts' may be omitted, and if included will be ignored, replaced with the host that is specifically +requesting the playbooks be executed. + +Also, the playbooks will be executed on the deployment server. Hence it may be slower in aggregate than +running content under scripts/ which ask much less of the deployment server + +Here is an example of what a playbook would look like broadly: + +- name: Example + gather_facts: no + tasks: + - name: Example1 + lineinfile: + path: /etc/hosts + line: 1.2.3.4 test1 + create: yes + - name: Example2 + lineinfile: + path: /etc/hosts + line: 1.2.3.5 test2 + create: yes + diff --git a/confluent_osdeploy/genesis/profiles/default/scripts/functions b/confluent_osdeploy/genesis/profiles/default/scripts/functions index 14bce404..53d21baf 100644 --- a/confluent_osdeploy/genesis/profiles/default/scripts/functions +++ b/confluent_osdeploy/genesis/profiles/default/scripts/functions @@ -63,3 +63,20 @@ run_remote_python() { cd - > /dev/null return $retcode } + +run_remote_config() { + echo + set_confluent_vars + apiclient=/opt/confluent/bin/apiclient + if [ -f /etc/confluent/apiclient ]; then + apiclient=/etc/confluent/apiclient + fi + echo '---------------------------------------------------------------------------' + echo Requesting to run remote configuration for "'$*'" from $mgr under profile $profile + /usr/libexec/platform-python $apiclient /confluent-api/self/remoteconfig/"$*" -d {} + /usr/libexec/platform-python $apiclient /confluent-api/self/remoteconfig/status -w 204 + echo + echo 'Completed remote configuration + echo '---------------------------------------------------------------------------' + return +} diff --git a/confluent_osdeploy/genesis/profiles/default/scripts/onboot.sh b/confluent_osdeploy/genesis/profiles/default/scripts/onboot.sh index 6b17fa33..12cf0d91 100644 --- a/confluent_osdeploy/genesis/profiles/default/scripts/onboot.sh +++ b/confluent_osdeploy/genesis/profiles/default/scripts/onboot.sh @@ -6,6 +6,9 @@ # run_remote and run_remote_python are available to download scripts and # execute them. +# Induce execution of remote configuration, e.g. ansible plays in ansible/onboot.d/ +run_remote_config onboot + # This is an example to request the BMC be configured on the network # according to how confluent has things configured: # run_remote_python configbmc -c