Add support for running crontabs in containers
authorOliver Walsh <owalsh@redhat.com>
Thu, 29 Jun 2017 12:59:26 +0000 (13:59 +0100)
committerOliver Walsh <owalsh@redhat.com>
Wed, 12 Jul 2017 10:01:07 +0000 (11:01 +0100)
This change enables the puppet cron resource in docker-puppet.py and adds user
crontabs to the paths copied from the config containers.

Only the nova crontab is configured for now. Other services will require
similar changes to run their crontabs.

Partial-Bug: 1701254

Change-Id: I2d1d0f0d77908a132472cf4bc475f8bd526af504
Depends-On: Ie16fb4539481a3c192cff8220a97daa4c70467fc

docker/docker-puppet.py
docker/services/README.rst
docker/services/nova-api.yaml

index 65d3bf3..01acde0 100755 (executable)
@@ -205,7 +205,7 @@ def mp_puppet_config((config_volume, puppet_tags, manifest, config_image, volume
 
         # Disables archiving
         if [ -z "$NO_ARCHIVE" ]; then
-            archivedirs=("/etc" "/root" "/opt" "/var/lib/ironic/tftpboot" "/var/lib/ironic/httpboot" "/var/www")
+            archivedirs=("/etc" "/root" "/opt" "/var/lib/ironic/tftpboot" "/var/lib/ironic/httpboot" "/var/www" "/var/spool/cron")
             rsync_srcs=""
             for d in "${archivedirs[@]}"; do
                 if [ -d "$d" ]; then
@@ -308,9 +308,9 @@ for config_volume in configs:
     volumes = service[4] if len(service) > 4 else []
 
     if puppet_tags:
-        puppet_tags = "file,file_line,concat,augeas,%s" % puppet_tags
+        puppet_tags = "file,file_line,concat,augeas,cron,%s" % puppet_tags
     else:
-        puppet_tags = "file,file_line,concat,augeas"
+        puppet_tags = "file,file_line,concat,augeas,cron"
 
     process_map.append([config_volume, puppet_tags, manifest, config_image, volumes])
 
index 84ac842..ce255ba 100644 (file)
@@ -74,7 +74,7 @@ are re-asserted when applying latter ones.
      * puppet_tags: Puppet resource tag names that are used to generate config
        files with puppet. Only the named config resources are used to generate
        a config file. Any service that specifies tags will have the default
-       tags of 'file,concat,file_line,augeas' appended to the setting.
+       tags of 'file,concat,file_line,augeas,cron' appended to the setting.
        Example: keystone_config
 
      * config_volume: The name of the volume (directory) where config files
index 93935ca..9282c93 100644 (file)
@@ -158,7 +158,7 @@ outputs:
             user: nova
             privileged: true
             restart: always
-            volumes:
+            volumes: &nova_api_volumes
               list_concat:
                 - {get_attr: [ContainersCommon, volumes]}
                 -
@@ -167,6 +167,16 @@ outputs:
                   - /var/log/containers/nova:/var/log/nova
             environment:
               - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
+          nova_api_cron:
+            image: *nova_api_image
+            net: host
+            user: root
+            privileged: true
+            restart: always
+            volumes: *nova_api_volumes
+            environment:
+              - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
+            command: "/usr/sbin/crond -n"
         step_5:
           nova_api_discover_hosts:
             start_order: 1