Uplift base image for hostconfig-operator
* uplift ansible-operator image from v0.17.0 to v1.13.1 * add cleanup for dnf cache * copy callback plugin to correct ansible path * update python version in inventory and filters * update inventory variables and annotations to align with ansible-operator greater than v1.0 Signed-off-by: Sreejith Punnapuzha <Sreejith.Punnapuzha@outlook.com> Change-Id: I0aa5b17fec91d589d1dce0e76f1de3ed07b002f8
This commit is contained in:
parent
6af4deb077
commit
9d263d74ee
11
Dockerfile
11
Dockerfile
@ -1,10 +1,10 @@
|
||||
# Ansible Operator base image
|
||||
FROM quay.io/operator-framework/ansible-operator:v0.17.0
|
||||
FROM quay.io/operator-framework/ansible-operator:v1.13.1
|
||||
|
||||
# Installing dependency libraries
|
||||
COPY airship-host-config/requirements.yml ${HOME}/requirements.yml
|
||||
RUN ansible-galaxy collection install -r ${HOME}/requirements.yml \
|
||||
&& chmod -R ug+rwx ${HOME}/.ansible
|
||||
&& chmod -R ug+rwx ${HOME}/.ansible
|
||||
|
||||
# Installing ssh clients - used to connect to kubernetes nodes
|
||||
USER root
|
||||
@ -15,8 +15,9 @@ RUN dnf install dbus libnghttp2 python3-librepo dbus-libs librepo dbus-daemon \
|
||||
platform-python-pip python3-pip libcom_err gnupg2 vim-minimal libstdc++ \
|
||||
python3-libs systemd-libs libssh-config glib2 python3-pip-wheel libsolv \
|
||||
gdb-gdbserver sqlite-libs libgcrypt libgcc pcre2 glibc-common expat libxml2 \
|
||||
libcurl glibc-minimal-langpack libpcap openssh-clients sshpass -y
|
||||
USER ansible-operator
|
||||
libcurl glibc-minimal-langpack libpcap openssh-clients sshpass -y \
|
||||
&& dnf clean all && rm -rf /var/cache/yum
|
||||
USER ansible
|
||||
|
||||
# Configuration for ansible
|
||||
COPY airship-host-config/build/ansible.cfg /etc/ansible/ansible.cfg
|
||||
@ -39,7 +40,7 @@ COPY airship-host-config/plugins/ ${HOME}/plugins/
|
||||
# ansible-runner unable to pick custom callback plugins specified in any other directory other than /usr/local/lib/python3.6/site-packages/ansible/plugins/callback
|
||||
# ansible-runner is overriding the ANSIBLE_CALLBACK_PLUGINS Environment variable
|
||||
# https://github.com/ansible/ansible-runner/blob/stable/1.3.x/ansible_runner/runner_config.py#L178
|
||||
COPY airship-host-config/plugins/callback/hostconfig_k8_cr_status.py /usr/local/lib/python3.6/site-packages/ansible/plugins/callback/
|
||||
COPY airship-host-config/plugins/callback/hostconfig_k8_cr_status.py /usr/local/lib/python3.8/site-packages/ansible/plugins/callback/
|
||||
|
||||
# Copying scripts folder used by exec configuration
|
||||
COPY airship-host-config/scripts/ ${HOME}/scripts/
|
||||
|
@ -33,6 +33,9 @@ spec:
|
||||
- name: airship-host-config
|
||||
image: "AIRSHIP_HOSTCONFIG_IMAGE"
|
||||
imagePullPolicy: "PULL_POLICY"
|
||||
args:
|
||||
- --leader-elect
|
||||
- --leader-election-id=airship-host-config
|
||||
volumeMounts:
|
||||
- mountPath: /tmp/ansible-operator/runner
|
||||
name: runner
|
||||
@ -45,8 +48,6 @@ spec:
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.name
|
||||
- name: OPERATOR_NAME
|
||||
value: "airship-host-config"
|
||||
- name: ANSIBLE_FILTER_PLUGINS
|
||||
value: /opt/ansible/plugins/filter
|
||||
- name: ANSIBLE_FORKS
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env python3.8
|
||||
|
||||
# Python code to build Inventory dynamically based on the kubernetes nodes
|
||||
# present in the cluster and labels and annotations associated
|
||||
|
@ -55,8 +55,8 @@ class CallbackModule(CallbackBase):
|
||||
def v2_playbook_on_play_start(self, play):
|
||||
self.vm = play.get_variable_manager()
|
||||
self.host_vars = self.vm.get_vars()['hostvars']
|
||||
self.hostConfigName = self.host_vars['localhost']['meta']['name']
|
||||
self.namespace = self.host_vars['localhost']['meta']['namespace']
|
||||
self.hostConfigName = self.host_vars['localhost']['ansible_operator_meta']['name']
|
||||
self.namespace = self.host_vars['localhost']['ansible_operator_meta']['namespace']
|
||||
|
||||
# This function is triggered when a certain task fails with
|
||||
# unreachable state
|
||||
@ -119,7 +119,7 @@ class CallbackModule(CallbackBase):
|
||||
if k8_hostname not in self.host_config_status.keys():
|
||||
self.host_config_status[k8_hostname] = dict()
|
||||
if task_name in self.host_config_status[k8_hostname].keys():
|
||||
status[task_name] = host_config_status[k8_hostname][task_name]
|
||||
status[task_name] = self.host_config_status[k8_hostname][task_name]
|
||||
status[task_name] = dict()
|
||||
check_keys = ["stdout", "stderr", "msg"]
|
||||
for key in check_keys:
|
||||
@ -210,7 +210,7 @@ class CallbackModule(CallbackBase):
|
||||
['_hostconfig_airshipit_org_hostconfig']\
|
||||
['metadata']['annotations']
|
||||
reconcile_status = dict()
|
||||
if "ansible.operator-sdk/reconcile-period" in annotations.keys():
|
||||
if "ansible.sdk.operatorframework.io/reconcile-period" in annotations.keys():
|
||||
iterations = 0
|
||||
pre_iter = None
|
||||
if 'reconcileStatus' in cr_obj['status'].keys() and \
|
||||
@ -219,12 +219,12 @@ class CallbackModule(CallbackBase):
|
||||
pre_iter = cr_obj['status']['reconcileStatus']\
|
||||
['completed_iterations']
|
||||
# Checks if the reconcile-interval or period is specified
|
||||
if "ansible.operator-sdk/reconcile-interval" in annotations.keys():
|
||||
if "ansible.sdk.operatorframework.io/reconcile-interval" in annotations.keys():
|
||||
# Calculates the iterations based on the reconcile-interval
|
||||
# This executes for the very first iteration only
|
||||
if pre_iter is None:
|
||||
interval = annotations["ansible.operator-sdk/reconcile-interval"]
|
||||
period = annotations["ansible.operator-sdk/reconcile-period"]
|
||||
interval = annotations["ansible.sdk.operatorframework.io/reconcile-interval"]
|
||||
period = annotations["ansible.sdk.operatorframework.io/reconcile-period"]
|
||||
iterations = self.get_iterations_from_interval(
|
||||
interval, period)
|
||||
reconcile_status['total_iterations'] = iterations
|
||||
@ -244,9 +244,9 @@ class CallbackModule(CallbackBase):
|
||||
"format not specified" in iterations:
|
||||
reconcile_status['msg'] = iterations
|
||||
return reconcile_status
|
||||
elif "ansible.operator-sdk/reconcile-iterations" \
|
||||
elif "ansible.sdk.operatorframework.io/reconcile-iterations" \
|
||||
in annotations.keys():
|
||||
iterations = annotations["ansible.operator-sdk/reconcile-iterations"]
|
||||
iterations = annotations["ansible.sdk.operatorframework.io/reconcile-iterations"]
|
||||
else:
|
||||
reconcile_status['msg'] = "Reconcile iterations or interval "+\
|
||||
"not specified. Running simple reconcile."
|
||||
@ -271,7 +271,7 @@ class CallbackModule(CallbackBase):
|
||||
reconcile_status['completed_iterations'] = current_iter
|
||||
if int(current_iter) == int(iterations)-1:
|
||||
cr_obj["metadata"]["annotations"]\
|
||||
["ansible.operator-sdk/reconcile-period"] = "0"
|
||||
["ansible.sdk.operatorframework.io/reconcile-period"] = "0"
|
||||
self.custom_api_instance.patch_namespaced_custom_object(
|
||||
group="hostconfig.airshipit.org",
|
||||
version="v1alpha1",
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python3
|
||||
#!/usr/bin/python3.8
|
||||
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python3
|
||||
#!/usr/bin/python3.8
|
||||
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python3
|
||||
#!/usr/bin/python3.8
|
||||
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python3
|
||||
#!/usr/bin/python3.8
|
||||
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
@ -6,7 +6,7 @@ apiVersion: hostconfig.airshipit.org/v1alpha1
|
||||
kind: HostConfig
|
||||
metadata:
|
||||
annotations:
|
||||
ansible.operator-sdk/reconcile-period: "30s"
|
||||
ansible.sdk.operatorframework.io/reconcile-period: "30s"
|
||||
name: example9
|
||||
spec:
|
||||
host_groups:
|
||||
|
@ -6,8 +6,8 @@ apiVersion: hostconfig.airshipit.org/v1alpha1
|
||||
kind: HostConfig
|
||||
metadata:
|
||||
annotations:
|
||||
ansible.operator-sdk/reconcile-period: "30s"
|
||||
ansible.operator-sdk/reconcile-interval: "2m40s"
|
||||
ansible.sdk.operatorframework.io/reconcile-period: "30s"
|
||||
ansible.sdk.operatorframework.io/reconcile-interval: "2m40s"
|
||||
name: example11
|
||||
spec:
|
||||
host_groups:
|
||||
|
@ -6,8 +6,8 @@ apiVersion: hostconfig.airshipit.org/v1alpha1
|
||||
kind: HostConfig
|
||||
metadata:
|
||||
annotations:
|
||||
ansible.operator-sdk/reconcile-period: "30s"
|
||||
ansible.operator-sdk/reconcile-iterations: "3"
|
||||
ansible.sdk.operatorframework.io/reconcile-period: "30s"
|
||||
ansible.sdk.operatorframework.io/reconcile-iterations: "3"
|
||||
name: example10
|
||||
spec:
|
||||
host_groups:
|
||||
|
Loading…
Reference in New Issue
Block a user