From 00ee297f522bec236a90932c73b90cde709e0e4e Mon Sep 17 00:00:00 2001 From: Lennard Brinkhaus Date: Fri, 15 Sep 2023 11:31:38 +0200 Subject: [PATCH] feat: create a specific podman user --- README.md | 38 +++----------------------------------- tasks/configure.yml | 2 -- tasks/main.yml | 2 ++ tasks/setup_user.yml | 15 +++++++++++++++ tasks/systemd-services.yml | 19 +++++++++++-------- 5 files changed, 31 insertions(+), 45 deletions(-) create mode 100644 tasks/setup_user.yml diff --git a/README.md b/README.md index 225dd44..53be4ff 100644 --- a/README.md +++ b/README.md @@ -1,38 +1,6 @@ -Role Name +Podman Role ========= -A brief description of the role goes here. +A role to compile a specific podman version and run it rootless. +Orientated at a Bash-Script from m-spezial.de -Requirements ------------- - -Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. - -Role Variables --------------- - -A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. - -Dependencies ------------- - -A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. - -Example Playbook ----------------- - -Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: - - - hosts: servers - roles: - - { role: username.rolename, x: 42 } - -License -------- - -BSD - -Author Information ------------------- - -An optional section for the role authors to include contact information, or a website (HTML is not allowed). diff --git a/tasks/configure.yml b/tasks/configure.yml index e4eb2f9..4e35c9d 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -62,5 +62,3 @@ dest: /etc/profile.d/podman.sh content: 'PATH=$PATH:/usr/libexec/podman' -- name: Exec lingur - shell: loginctl enable-linger 1000 diff --git a/tasks/main.yml b/tasks/main.yml index 5b8b744..ed4ae39 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -2,6 +2,8 @@ - name: Gather variables for each operating system include_vars: "{{ ansible_distribution | lower }}.yml" +- include_tasks: setup_user.yml + - include_tasks: install.yml - include_tasks: systemd-services.yml diff --git a/tasks/setup_user.yml b/tasks/setup_user.yml new file mode 100644 index 0000000..cf474fa --- /dev/null +++ b/tasks/setup_user.yml @@ -0,0 +1,15 @@ +- name: Setup podman user + user: + create_home: true + name: podman_rootless + shell: /bin/bash + uid: 2534 + groups: + - podman_rootless + - cdrom + - floppy + - audio + - dip + - video + - plugdev + - netdev diff --git a/tasks/systemd-services.yml b/tasks/systemd-services.yml index 131f4d2..d8a7bc0 100644 --- a/tasks/systemd-services.yml +++ b/tasks/systemd-services.yml @@ -1,14 +1,17 @@ -- name: Setup podman-docker service - systemd_service: - enabled: true - state: started +- name: "Reload systemd" + ansible.builtin.systemd: daemon_reload: true - name: podman-docker -- name: Setup podman.sock - remote_user: alphyron +- name: Setup podman.socket + become: yes + become_user: podman_rootless systemd_service: enabled: true - name: podman.sock + name: podman.socket state: started scope: "user" + environment: + XDG_RUNTIME_DIR: /run/user/2534 + +- name: Exec lingur + shell: loginctl enable-linger 1000