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
|
# tasks file for roles/init-vps
|
||||||
# @TODO complete below tasks
|
# @TODO complete below tasks
|
||||||
- name: Checking whether administrative login used
|
- 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:
|
ansible.builtin.fail:
|
||||||
msg: Must use administrative user for subsequent tasks
|
msg: Must use administrative user for subsequent tasks
|
||||||
- name: Setting approved SSH authentication procedures
|
- name: Setting approved SSH authentication procedures
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
backup: true
|
backup: true
|
||||||
validate: "sshd -t %s"
|
validate: "sshd -t %s"
|
||||||
- name: Create groups for FTP services
|
- 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
|
become: true
|
||||||
ansible.builtin.group:
|
ansible.builtin.group:
|
||||||
name: "{{ item.username }}"
|
name: "{{ item.username }}"
|
||||||
@@ -45,13 +45,25 @@
|
|||||||
- name: Configuring SFTP for FTP group
|
- name: Configuring SFTP for FTP group
|
||||||
when: ansible_facts["system"] == "Linux"
|
when: ansible_facts["system"] == "Linux"
|
||||||
become: true
|
become: true
|
||||||
ansible.builtin.template:
|
ansible.builtin.blockinfile:
|
||||||
src: sshd_config.d/sftp.conf.j2
|
# src: sshd_config.d/sftp.conf.j2
|
||||||
dest: /etc/ssh/sshd_config.d/sftp.conf
|
# 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
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: "644"
|
mode: "644"
|
||||||
force: true
|
|
||||||
backup: true
|
backup: true
|
||||||
validate: "sshd -t %s"
|
validate: "sshd -t %s"
|
||||||
|
state: present
|
||||||
|
loop: "{{ ftp_groups.results }}"
|
||||||
register: configured_sftp
|
register: configured_sftp
|
||||||
Reference in New Issue
Block a user