From 9f43029353d62cf174be2ecae401734a0a279974 Mon Sep 17 00:00:00 2001 From: Markus Pesch Date: Wed, 8 Feb 2023 18:25:07 +0100 Subject: [PATCH] fix: add linter --- meta/main.yml | 4 ---- tasks/create_unix_group.yml | 4 ++-- tasks/create_unix_user.yml | 24 ++++++++++++------------ tasks/remove_unix_group.yml | 2 +- tasks/remove_unix_user.yml | 2 +- 5 files changed, 16 insertions(+), 20 deletions(-) diff --git a/meta/main.yml b/meta/main.yml index a43bf34..8b881fd 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -16,8 +16,4 @@ galaxy_info: versions: - "35" - galaxy_tags: - - unix_users - - unix_groups - dependencies: [] diff --git a/tasks/create_unix_group.yml b/tasks/create_unix_group.yml index ecce0dc..4068a19 100644 --- a/tasks/create_unix_group.yml +++ b/tasks/create_unix_group.yml @@ -4,11 +4,11 @@ group: name: "{{ unix_group.key }}" state: "{{ unix_group.value.state | default('present') }}" - when: unix_group.value.gid is not defined or unix_group.value.gid is defined and unix_group.value.gid == "" + when: unix_group.value.gid is not defined or unix_group.value.gid is defined and unix_group.value.gid | length <= 0 - name: Create unix group {{ unix_group.key }} with pre-defined gid group: name: "{{ unix_group.key }}" gid: "{{ unix_group.value.gid }}" state: "{{ unix_group.value.state | default('present') }}" - when: unix_group.value.gid is defined and unix_group.value.gid != "" \ No newline at end of file + when: unix_group.value.gid is defined and unix_group.value.gid | length > 0 diff --git a/tasks/create_unix_user.yml b/tasks/create_unix_user.yml index 5a84bb7..e42fa77 100644 --- a/tasks/create_unix_user.yml +++ b/tasks/create_unix_user.yml @@ -1,8 +1,8 @@ --- - name: Define home directory for user {{ unix_user.key }} - set_fact: - user_user_home: "{{ unix_user.value.home | default('/home/' + unix_user.key) }}" + ansible.builtin.set_fact: + user_user_home: "{{ unix_user.value.home | default('/home/' + unix_user.key) }}" - name: Create unix user {{ unix_user.key }} without additional groups and uid user: @@ -57,7 +57,7 @@ when: "unix_user.value.groups is defined and unix_user.value.uid is not defined" - name: Create .ssh directory for user {{ unix_user.key }} - file: + ansible.builtin.file: path: "{{ user_user_home }}/.ssh" owner: "{{ unix_user.key }}" group: "{{ unix_user.value.group | default('users') }}" @@ -65,7 +65,7 @@ state: directory - name: Create authorized_keys file for user {{ unix_user.key }} - template: + ansible.builtin.template: src: authorized_keys.j2 dest: "{{ user_user_home }}/.ssh/authorized_keys" owner: "{{ unix_user.key }}" @@ -74,13 +74,13 @@ when: unix_user.value.ssh.authorized_keys is defined and unix_user.value.ssh.authorized_keys | length > 0 - name: Remove authorized_keys file for user {{ unix_user.key }} - file: + ansible.builtin.file: path: "{{ user_user_home }}/.ssh/authorized_keys" state: absent when: unix_user.value.ssh.authorized_keys is not defined or unix_user.value.ssh.authorized_keys | length <= 0 - name: Create private SSH keys for user {{ unix_user.key }} - copy: + ansible.builtin.copy: src: "{{ playbook_dir }}/ssh/private_keys/{{ item }}" dest: "{{ user_user_home }}/.ssh/{{ item }}" owner: "{{ unix_user.key }}" @@ -101,7 +101,7 @@ when: unix_user.value.ssh.private_keys is defined and unix_user.value.ssh.private_keys | length >= 0 - name: Correct permissions of public SSH keys for user {{ unix_user.key }} - file: + ansible.builtin.file: path: "{{ user_user_home }}/.ssh/{{ item }}.pub" owner: "{{ unix_user.key }}" group: "{{ unix_user.value.group | default('users') }}" @@ -111,7 +111,7 @@ when: unix_user.value.ssh.private_keys is defined and unix_user.value.ssh.private_keys | length >= 0 - name: Create custom SSH client config for user {{ unix_user.key }} - template: + ansible.builtin.template: src: config.j2 dest: "{{ user_user_home }}/.ssh/config" owner: "{{ unix_user.key }}" @@ -120,13 +120,13 @@ when: unix_user.value.ssh.config is defined and unix_user.value.ssh.config | length >= 0 - name: Remove custom SSH client config for user {{ unix_user.key }} - file: + ansible.builtin.file: path: "{{ user_user_home }}/.ssh/config" state: absent when: unix_user.value.ssh.config is not defined - name: Create .forward file to forward emails for user {{ unix_user.key }} - template: + ansible.builtin.template: src: forward.j2 dest: "{{ user_user_home }}/.forward" owner: "{{ unix_user.key }}" @@ -135,7 +135,7 @@ when: unix_user.value.email is defined - name: Remove .forward file to forward emails for user {{ unix_user.key }} - file: + ansible.builtin.file: path: "{{ user_user_home }}/.forward" state: absent - when: unix_user.value.email is not defined \ No newline at end of file + when: unix_user.value.email is not defined diff --git a/tasks/remove_unix_group.yml b/tasks/remove_unix_group.yml index fd45ddd..92a796c 100644 --- a/tasks/remove_unix_group.yml +++ b/tasks/remove_unix_group.yml @@ -3,4 +3,4 @@ - name: Remove unix group {{ unix_group.key }} group: name: "{{ unix_group.key }}" - state: absent \ No newline at end of file + state: absent diff --git a/tasks/remove_unix_user.yml b/tasks/remove_unix_user.yml index 372b7a2..76c675f 100644 --- a/tasks/remove_unix_user.yml +++ b/tasks/remove_unix_user.yml @@ -4,4 +4,4 @@ user: name: "{{ unix_user.key }}" state: absent - remove: yes \ No newline at end of file + remove: true