changed variable used in conditional case, altered task modifying/creating sftp configuration file for SSH to use blockinfile module
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
# tasks file for roles/init-vps
|
||||
# @TODO complete below tasks
|
||||
- name: Checking whether administrative login used
|
||||
when: ansible_facts["user_id"] not in (admins | map(attribute="username") | list)
|
||||
when: ansible_user not in (admins | map(attribute="username") | list)
|
||||
ansible.builtin.fail:
|
||||
msg: Must use administrative user for subsequent tasks
|
||||
- name: Setting approved SSH authentication procedures
|
||||
@@ -34,7 +34,7 @@
|
||||
backup: true
|
||||
validate: "sshd -t %s"
|
||||
- name: Create groups for FTP services
|
||||
when: "'internal-sftp' in item.service or 'proftpd' in item.service or 'vsftpd' in item.service"
|
||||
when: "'sftp-server' in item.service or 'proftpd' in item.service or 'vsftpd' in item.service"
|
||||
become: true
|
||||
ansible.builtin.group:
|
||||
name: "{{ item.username }}"
|
||||
@@ -45,13 +45,25 @@
|
||||
- name: Configuring SFTP for FTP group
|
||||
when: ansible_facts["system"] == "Linux"
|
||||
become: true
|
||||
ansible.builtin.template:
|
||||
src: sshd_config.d/sftp.conf.j2
|
||||
dest: /etc/ssh/sshd_config.d/sftp.conf
|
||||
ansible.builtin.blockinfile:
|
||||
# src: sshd_config.d/sftp.conf.j2
|
||||
# dest: /etc/ssh/sshd_config.d/sftp.conf
|
||||
path: /etc/ssh/sshd_config.d/sftp.conf
|
||||
block: |
|
||||
Match Group {{ item.name }}
|
||||
ForceCommand internal-sftp -d /%u
|
||||
ChrootDirectory /srv/{{ item.name}}
|
||||
AllowAgentForwarding no
|
||||
AllowTcpForwarding no
|
||||
X11Forwarding no
|
||||
append_newline: true
|
||||
marker_begin: "BEGIN FTP GROUP SSH MATCH BLOCK"
|
||||
create: true
|
||||
owner: root
|
||||
group: root
|
||||
mode: "644"
|
||||
force: true
|
||||
backup: true
|
||||
validate: "sshd -t %s"
|
||||
state: present
|
||||
loop: "{{ ftp_groups.results }}"
|
||||
register: configured_sftp
|
||||
Reference in New Issue
Block a user