Run update mirrors script as regular user
diff --git a/aptly/server/mirrors.sls b/aptly/server/mirrors.sls
index 7f7fa33..5128620 100644
--- a/aptly/server/mirrors.sls
+++ b/aptly/server/mirrors.sls
@@ -4,11 +4,15 @@
aptly_mirror_update_cron:
cron.present:
- - name: "service aptly-api stop >/dev/null;sleep 5;su aptly -c '/usr/local/bin/aptly_mirror_update.sh -s';service aptly-api start >/dev/null"
+ - name: "/usr/local/bin/aptly_mirror_update.sh -s"
- identifier: aptly_mirror_update
- hour: "{{ server.mirror_update.hour }}"
- minute: "{{ server.mirror_update.minute }}"
+ {%- if server.source.engine != "docker" %}
+ - user: {{ server.user.name }}
+ {%- else %}
- user: root
+ {%- endif %}
- require:
- file: aptly_mirror_update_script
- user: aptly_user
@@ -16,13 +20,29 @@
cron_path:
cron.env_present:
- name: PATH
- - value: "/bin:/sbin:/usr/bin:/usr/sbin"
+ - value: "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
+
+{# TODO: remove me after some time #}
+aptly_mirror_update_cron_absent_obsolete:
+ cron.absent:
+ - identifier: aptly_mirror_update
+ - user: root
{%- else %}
aptly_mirror_update_cron:
cron.absent:
- identifier: aptly_mirror_update
+ {%- if server.source.engine != "docker" %}
+ - user: {{ server.user.name }}
+ {%- else %}
+ - user: root
+ {%- endif %}
+
+{# TODO: remove me after some time #}
+aptly_mirror_update_cron_obsolete:
+ cron.absent:
+ - identifier: aptly_mirror_update
- user: root
{% endif %}
@@ -38,7 +58,7 @@
cmd.run:
- name: gpg --no-tty --no-default-keyring{% if server.gpg.get('keyring', None) %} --keyring {{ server.gpg.keyring }} {% endif %}{% if server.gpg.get('homedir', None) %} --homedir {{ server.gpg.homedir }} {% endif %}--keyserver {{ mirror.keyserver|default(server.gpg.keyserver) }} --recv-keys {{ gpgkey }}
{%- if server.source.engine != "docker" %}
- - user: aptly
+ - user: {{ server.user.name }}
- cwd: {{ server.home_dir }}
{%- endif %}
- unless: gpg --no-tty --no-default-keyring{% if server.gpg.get('keyring', None) %} --keyring {{ server.gpg.keyring }} {% endif %}{% if server.gpg.get('homedir', None) %} --homedir {{ server.gpg.homedir }} {% endif %}--list-public-keys {{gpgkey}}
@@ -51,7 +71,7 @@
cmd.run:
- name: aptly snapshot create {{ snapshot }} from mirror {{ mirror_name }}
{%- if server.source.engine != "docker" %}
- - user: aptly
+ - user: {{ server.user.name }}
{%- endif %}
- unless: aptly snapshot show {{ snapshot }}
- require:
@@ -63,7 +83,7 @@
cmd.run:
- name: aptly mirror create {% if mirror.get('udebs', False) %}-with-udebs=true {% endif %}{% if mirror.get('sources', False) %}-with-sources=true {% endif %}-architectures={{ mirror.architectures }} {{ mirror_name }} {{ mirror.source }} {{ mirror.distribution }} {{ mirror.components }}
{%- if server.source.engine != "docker" %}
- - user: aptly
+ - user: {{ server.user.name }}
{%- endif %}
- unless: aptly mirror show {{ mirror_name }}
@@ -72,7 +92,7 @@
cmd.run:
- name: aptly mirror update {{ mirror_name }}
{%- if server.source.engine != "docker" %}
- - user: aptly
+ - user: {{ server.user.name }}
{%- endif %}
- require:
- cmd: aptly_{{ mirror_name }}_mirror
@@ -83,7 +103,7 @@
cmd.run:
- name: aptly publish snapshot -batch=true -gpg-key='{{ server.gpg.keypair_id }}' -passphrase='{{ server.gpg.passphrase }}' {{ server.mirror[mirror_name].publish }}
{%- if server.source.engine != "docker" %}
- - user: aptly
+ - user: {{ server.user.name }}
{%- endif %}
{% endif %}