From f9b73ce9093c8e11aaebd0dc89c8436f3fbb4d4b Mon Sep 17 00:00:00 2001 From: Michel Jouvin Date: Wed, 27 Oct 2021 12:46:20 +0200 Subject: [PATCH 1/2] features/docker: add support for an extra YUM repository - Also include backward-compatible inor additions/improvements --- features/docker/backup.pan | 4 +++- features/docker/config.pan | 1 + features/docker/core.pan | 5 ++++- features/docker/el7/daemon_config.pan | 6 +++++- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/features/docker/backup.pan b/features/docker/backup.pan index 94515521..c7e64219 100644 --- a/features/docker/backup.pan +++ b/features/docker/backup.pan @@ -22,9 +22,11 @@ variable DOCKER_BACKUP_COMMAND ?= format("/usr/sbin/backup_docker_data -dir %s % variable DOCKER_BACKUP_FREQUENCY ?= "30 11 * * *"; +variable DOCKER_BACKUP_SCRIPT ?= 'features/docker/backup_docker_data'; + include 'components/filecopy/config'; '/software/components/filecopy/services/{/usr/sbin/backup_docker_data}' = dict( - "config", file_contents('features/docker/backup_docker_data'), + "config", file_contents(DOCKER_BACKUP_SCRIPT), "owner", "root", "perms", "0755", ); diff --git a/features/docker/config.pan b/features/docker/config.pan index fc390b29..0b9345f3 100644 --- a/features/docker/config.pan +++ b/features/docker/config.pan @@ -48,6 +48,7 @@ include if( DOCKER_PIPEWORK ) 'features/docker/pipework'; # Configure Docker YUM repository if necessary variable SITE_REPOSITORY_LIST = { + debug('DOCKER_YUM_REPOSITORY=%s', to_string(DOCKER_YUM_REPOSITORY)); if ( is_defined(DOCKER_YUM_REPOSITORY) ) { SELF[length(SELF)] = format('%s', DOCKER_YUM_REPOSITORY); }; diff --git a/features/docker/core.pan b/features/docker/core.pan index e75f5395..e689e4e3 100644 --- a/features/docker/core.pan +++ b/features/docker/core.pan @@ -1,10 +1,13 @@ unique template features/docker/core; +# Some docker dependencies are provided in extras repo +variable REPOSITORY_CENTOS_EXTRAS_ENABLED ?= true; + # OS dependent setup include if ( OS_VERSION_PARAMS['family'] == 'el' ) { format('features/docker/el%s/config', OS_VERSION_PARAMS['majorversion']); } else { - error(format('Docker configuration: unsupported OS version (%s)', OS_VERSION_PARAMS['major'])); + error('Docker configuration: unsupported OS version (%s)', OS_VERSION_PARAMS['major']); }; # Add Docker package (actual package name defined in OS variant) diff --git a/features/docker/el7/daemon_config.pan b/features/docker/el7/daemon_config.pan index 05c32fe8..dfe6ab09 100644 --- a/features/docker/el7/daemon_config.pan +++ b/features/docker/el7/daemon_config.pan @@ -15,7 +15,11 @@ variable DOCKER_DAEMON_CFG_CONTENT ?= { } else { sep = "\n"; }; - txt = txt + format('"%s": "%s"%s', name, value, sep); + if(is_string(value)){ + txt = txt + format('"%s": "%s"%s', name, value, sep); + }else{ + txt = txt + format('"%s": %s%s', name, value, sep); + }; i = i + 1; }; txt = txt + "}\n"; From bf5c80d2b7cd6ecba1deadb62a67d43982d0ba58 Mon Sep 17 00:00:00 2001 From: Michel Jouvin Date: Thu, 10 Mar 2022 12:01:26 +0100 Subject: [PATCH 2/2] Add Docker support for EL8 --- features/docker/el8/config.pan | 26 +++++++++++++++++++ features/docker/el8/daemon_config.pan | 37 +++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 features/docker/el8/config.pan create mode 100644 features/docker/el8/daemon_config.pan diff --git a/features/docker/el8/config.pan b/features/docker/el8/config.pan new file mode 100644 index 00000000..49d77574 --- /dev/null +++ b/features/docker/el8/config.pan @@ -0,0 +1,26 @@ +unique template features/docker/el8/config; + +variable DOCKER_PACKAGE ?= 'docker-ce'; + + +@{ +descr = options for the daemon.json +values = dict +default = data-root if defined (DOCKER_DATA_DIR variable) +required = No +} +variable DOCKER_SRV_OPTS ?= dict(); + +variable DOCKER_SRV_OPTS = { + if ( is_defined(DOCKER_DATA_DIR) ) { + SELF['data-root'] = DOCKER_DATA_DIR; + if ( !is_defined(SELF['storage-driver']) ) { + SELF['storage-driver'] = "overlay"; + }; + }; + + SELF; +}; + +# Configure daemon.json if needed +include if( length(DOCKER_SRV_OPTS) > 0 ) 'features/docker/el7/daemon_config'; diff --git a/features/docker/el8/daemon_config.pan b/features/docker/el8/daemon_config.pan new file mode 100644 index 00000000..1604a1d1 --- /dev/null +++ b/features/docker/el8/daemon_config.pan @@ -0,0 +1,37 @@ +unique template features/docker/el8/daemon_config; + +@{ +descr = daemon.json content +values = string +default = built using DOCKER_SRV_OPTS +required = No +} +variable DOCKER_DAEMON_CFG_CONTENT ?= { + txt = "{\n"; + i = 1; + foreach (name; value; DOCKER_SRV_OPTS) { + if ( i < length(DOCKER_SRV_OPTS) ) { + sep = ",\n"; + } else { + sep = "\n"; + }; + if(is_string(value)){ + txt = txt + format('"%s": "%s"%s', name, value, sep); + }else{ + txt = txt + format('"%s": %s%s', name, value, sep); + }; + i = i + 1; + }; + txt = txt + "}\n"; + txt; +}; + +# Create daemon config file +include 'components/filecopy/config'; +prefix '/software/components/filecopy/services'; +'{/etc/docker/daemon.json}' = dict("config", DOCKER_DAEMON_CFG_CONTENT, + "perms", "0644", + "restart", "systemctl restart docker", + ); + +