X-Git-Url: https://git.realraum.at/?a=blobdiff_plain;f=ansible%2Froles%2Fbase%2Ftasks%2Fmain.yaml;h=1e53273b4afec27d87de9100b1ef1b18c6b272ac;hb=d9a3cc9eb4fcbab709d6be1ea5b46dfdd88e48cc;hp=c6b9c6f0698fd2cf7c467351ba687b8c22020321;hpb=2efc4cf20ed8970f4a9505299476b971b48fbd82;p=noc.git diff --git a/ansible/roles/base/tasks/main.yaml b/ansible/roles/base/tasks/main.yaml index c6b9c6f..1e53273 100644 --- a/ansible/roles/base/tasks/main.yaml +++ b/ansible/roles/base/tasks/main.yaml @@ -6,20 +6,42 @@ line: "PermitRootLogin without-password" notify: restart ssh -- name: limit allowed users (1/2) +- name: limit allowed users (1/3) lineinfile: dest: /etc/ssh/sshd_config - regexp: "^AllowUsers" + regexp: "^#?AllowUsers" line: "AllowUsers {{ ' '.join([ 'root' ] | union(sshd_allowusers_group | default([])) | union(sshd_allowusers_host | default([]))) }}" - when: sshd_allowusers_set | default(true) + when: sshd_allowusers_set is defined and sshd_allowgroup is not defined notify: restart ssh -- name: limit allowed users (2/2) +- block: + - name: "limit allowed users (2/3): Make sure AllowUsers is not in sshd_config" + lineinfile: + dest: /etc/ssh/sshd_config + regexp: "^AllowUsers" + state: absent + + - name: "limit allowed users (2/3): Set AllowGroups in sshd_config" + lineinfile: + dest: /etc/ssh/sshd_config + regexp: "^#?AllowGroups" + line: AllowGroups {{ sshd_allowgroup }} + + - name: "limit allowed users (2/3): Add allowed users to ssh group" + user: + name: "{{ item }}" + groups: "{{ sshd_allowgroup }}" + append: True + with_items: "{{ [ 'root' ] | union(sshd_allowusers_group | default([])) | union(sshd_allowusers_host | default([])) }}" + + when: sshd_allowgroup is defined + +- name: limit allowed users (3/3) lineinfile: dest: /etc/ssh/sshd_config - regexp: "^AllowUsers" + regexp: "^Allow(Users|Groups)" state: absent - when: not sshd_allowusers_set | default(true) + when: sshd_allowusers_set is not defined and sshd_allowgroup is not defined notify: restart ssh - name: Set authorized keys for root user @@ -54,16 +76,22 @@ - zsh - python-apt -- name: install systemd specific packages - apt: name={{ item }} state=present - with_items: - - dbus - - libpam-systemd +- block: + - name: install systemd specific packages + apt: name={{ item }} state=present + with_items: + - dbus + - libpam-systemd + + - name: set systemd-related environment variables + copy: src=xdg_runtime_dir.sh dest=/etc/profile.d/xdg_runtime_dir.sh mode=0644 + when: ansible_service_mgr == "systemd" - name: install zshrc - copy: src={{ item.src }} dest={{ item.dest }} mode=0640 + copy: src={{ item.src }} dest={{ item.dest }} mode=0644 with_items: + - { "src": "zprofile", "dest": "/etc/zsh/zprofile" } - { "src": "zshrc", "dest": "/etc/zsh/zshrc" } - { "src": "zshrc.skel", "dest": "/etc/skel/.zshrc" }