Skip to content

Commit

Permalink
Merge pull request #144 from jouvin/docker_updates
Browse files Browse the repository at this point in the history
features/docker: add support for EL8 and for adding an extra YUM repository
  • Loading branch information
jrha committed Jul 21, 2023
2 parents 52cde16 + bf5c80d commit 970084e
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 3 deletions.
4 changes: 3 additions & 1 deletion features/docker/backup.pan
Expand Up @@ -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",
);
Expand Down
1 change: 1 addition & 0 deletions features/docker/config.pan
Expand Up @@ -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);
};
Expand Down
5 changes: 4 additions & 1 deletion 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)
Expand Down
6 changes: 5 additions & 1 deletion features/docker/el7/daemon_config.pan
Expand Up @@ -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";
Expand Down
26 changes: 26 additions & 0 deletions 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';
37 changes: 37 additions & 0 deletions 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",
);


0 comments on commit 970084e

Please sign in to comment.