From f8ddced6c933902485ac2e47bccb5f03e202c982 Mon Sep 17 00:00:00 2001 From: Jonathan Sieber Date: Thu, 4 Oct 2018 13:19:13 +0200 Subject: [PATCH 1/4] Postgres: Don't mess with specific non-default locales --- postgresql/defaults/main.yml | 4 ++-- tests/itedd.yml | 6 ------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/postgresql/defaults/main.yml b/postgresql/defaults/main.yml index a4d2a88..098047d 100644 --- a/postgresql/defaults/main.yml +++ b/postgresql/defaults/main.yml @@ -3,12 +3,12 @@ postgresql_version: "9.3" # table locale and character encoding -postgresql_locale: "en_US" +postgresql_locale: "C" postgresql_encoding: "UTF-8" # shell locale and character encoding postgresql_shell_locale: "{{ postgresql_locale }}" -postgresql_shell_encoding: "{{ postgresql_encoding | replace('-', '') | lower }}" +postgresql_shell_encoding: "{{ postgresql_encoding }}" # default application database db_user: '' # name of the user (empty means no user is created) diff --git a/tests/itedd.yml b/tests/itedd.yml index 3efcd7b..bb2504c 100644 --- a/tests/itedd.yml +++ b/tests/itedd.yml @@ -41,12 +41,6 @@ # pool: 5 pre_tasks: - - file: - path: '/etc/locale.gen' - state: 'absent' - - shell: 'locale-gen "en_US.UTF-8"' - changed_when: no - - name: Create App User user: name: "{{ app_user }}" From 112e2f87737fb13341159b2993d7bac9d83cbc68 Mon Sep 17 00:00:00 2001 From: Jonathan Sieber Date: Thu, 4 Oct 2018 13:26:12 +0200 Subject: [PATCH 2/4] Support for systemd user services --- systemd/usermanager/defaults/main.yml | 3 +++ systemd/usermanager/tasks/Debian.yml | 3 +++ systemd/usermanager/tasks/main.yml | 9 +++++++++ tests/itedd.yml | 7 +++++++ 4 files changed, 22 insertions(+) create mode 100644 systemd/usermanager/defaults/main.yml create mode 100644 systemd/usermanager/tasks/Debian.yml create mode 100644 systemd/usermanager/tasks/main.yml diff --git a/systemd/usermanager/defaults/main.yml b/systemd/usermanager/defaults/main.yml new file mode 100644 index 0000000..864ecc7 --- /dev/null +++ b/systemd/usermanager/defaults/main.yml @@ -0,0 +1,3 @@ +--- +# list of user names, that use systemd user manager +users: [] diff --git a/systemd/usermanager/tasks/Debian.yml b/systemd/usermanager/tasks/Debian.yml new file mode 100644 index 0000000..b9d5c0d --- /dev/null +++ b/systemd/usermanager/tasks/Debian.yml @@ -0,0 +1,3 @@ +- name: Debian | Install libpam for systemd + apt: + pkg: libpam-systemd diff --git a/systemd/usermanager/tasks/main.yml b/systemd/usermanager/tasks/main.yml new file mode 100644 index 0000000..208ef63 --- /dev/null +++ b/systemd/usermanager/tasks/main.yml @@ -0,0 +1,9 @@ +- include_tasks: Debian.yml + when: ansible_os_family == "Debian" + + +- name: Enable systemd User Manager + systemd: + name: user@{{ item }} + state: started + loop: "{{ users }}" diff --git a/tests/itedd.yml b/tests/itedd.yml index bb2504c..2a01d62 100644 --- a/tests/itedd.yml +++ b/tests/itedd.yml @@ -70,6 +70,13 @@ - role: dresden-weekly.Rails/upstart/userjobs users: - "{{ app_user }}" + when: ansible_service_mgr == "upstart" + + - role: dresden-weekly.Rails/systemd/usermanager + users: + - "{{ app_user }}" + when: ansible_service_mgr == "systemd" + - dresden-weekly.Rails/webrick/service - dresden-weekly.Rails/nginx/server - dresden-weekly.Rails/nginx/webrick From de91ef54e8227bb966a65c2c5c22342ada573e22 Mon Sep 17 00:00:00 2001 From: Jonathan Sieber Date: Thu, 4 Oct 2018 13:26:47 +0200 Subject: [PATCH 3/4] Enable Ubuntu 16.04 as Travis env --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1c41ecb..8a6745a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,10 +10,10 @@ env: # version: 7 # init: /usr/lib/systemd/systemd # run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro" - # - distribution: ubuntu - # version: 16.04 - # init: /sbin/init - # run_opts: "" + - distribution: ubuntu + version: 16.04 + init: /sbin/init + run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro --volume=/sys/fs/cgroup/systemd:/sys/fs/cgroup/systemd:rw" - distribution: ubuntu-upstart version: 14.04 init: /sbin/init From f404407c65bf37aa3ab5db8f530a1e270ef00764 Mon Sep 17 00:00:00 2001 From: Jonathan Sieber Date: Fri, 5 Oct 2018 10:21:34 +0200 Subject: [PATCH 4/4] More debug output for early failing systemd user managment --- systemd/usermanager/tasks/main.yml | 20 +++++++++++++ tests/itedd.yml | 6 ++++ webrick/service/tasks/systemd.yml | 45 ++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+) diff --git a/systemd/usermanager/tasks/main.yml b/systemd/usermanager/tasks/main.yml index 208ef63..f8aeb00 100644 --- a/systemd/usermanager/tasks/main.yml +++ b/systemd/usermanager/tasks/main.yml @@ -7,3 +7,23 @@ name: user@{{ item }} state: started loop: "{{ users }}" + + +- command: systemctl status user@deploy + register: foo + failed_when: false +- debug: var=foo + +- command: ps aux + register: psaux +- debug: var=psaux + + +- name: Check for systemd user session + shell: 'ps aux | grep "systemd --user" | grep -v grep' + register: bar + failed_when: bar.stdout == "" + + +- name: Print out result + debug: var=bar diff --git a/tests/itedd.yml b/tests/itedd.yml index 2a01d62..20a93a3 100644 --- a/tests/itedd.yml +++ b/tests/itedd.yml @@ -47,6 +47,12 @@ shell: /bin/bash roles: + + - role: dresden-weekly.Rails/systemd/usermanager + users: + - "{{ app_user }}" + when: ansible_service_mgr == "systemd" + - dresden-weekly.Rails/postgresql - dresden-weekly.Rails/ruby/rvm diff --git a/webrick/service/tasks/systemd.yml b/webrick/service/tasks/systemd.yml index 8b04fed..6e3b742 100644 --- a/webrick/service/tasks/systemd.yml +++ b/webrick/service/tasks/systemd.yml @@ -12,6 +12,36 @@ become: yes when: "{{ 'Failed' in systemd_linger_enabled_test.stderr }}" + + +- name: ps aux + command: "ps aux" + register: psaux +- debug: var=psaux + + + +- name: systemctl status + command: "systemctl status user@deploy" + register: systemctl + failed_when: false +- debug: var=systemctl + +- become_user: "{{ webrick_user }}" + block: + - name: env + command: "env" + register: envc + - debug: var=envc + + +- command: "sudo -iu {{ webrick_user }} env" + register: envs +- debug: var=envs + + + + - become_user: "{{ webrick_user }}" block: - name: "Systemd | Ensure complete .profile" @@ -20,6 +50,13 @@ regexp: "^export XDG_RUNTIME_DIR=" line: "export XDG_RUNTIME_DIR=/run/user/`id -u`" +- become_user: "{{ webrick_user }}" + block: + - name: env + command: "env" + register: envc + - debug: var=envc + - name: Systemd | Ensure the user units folder exists file: path: "{{ webrick_systemd_user_units }}" @@ -29,6 +66,14 @@ template: dest: "{{ webrick_systemd_unit }}" src: systemd.service.j2 + failed_when: false + + - name: Systemd | Enable unit at boot + shell: "/bin/bash -lc -- 'env'" + register: envb + + - debug: var=envb + - name: Systemd | Enable unit at boot shell: "/bin/bash -lc -- 'systemctl --user enable {{ webrick_service_name }}.service'"