machine_setup/ansible/roles/ssh_client/tasks/peruser.yaml

50 lines
1.3 KiB
YAML
Raw Normal View History

2022-10-27 05:43:04 +00:00
- include_role:
name: per_user
2024-02-11 19:59:55 +00:00
- name: Create directories
file:
name: "{{ account_homedir.stdout }}/{{ item }}"
state: directory
mode: 0700
owner: "{{ account_name.stdout }}"
group: "{{ group_name.stdout }}"
loop:
- ".ssh"
2022-10-27 05:43:04 +00:00
2024-02-11 19:59:55 +00:00
- name: Add ssh hosts to config
blockinfile:
path: "{{ account_homedir.stdout }}/.ssh/config"
marker: "# {mark} ANSIBLE MANAGED BLOCK {{ item.name }}"
create: true
mode: 0600
owner: "{{ account_name.stdout }}"
group: "{{ group_name.stdout }}"
block: |
Host {{ item.name }}
{% if item.proxy_jump is defined %}
ProxyJump {{ item.proxy_jump }}
{% endif %}
{% if item.host_name is defined %}
HostName {{ item.host_name }}
{% endif %}
when: ssh_hosts is defined
loop: "{{ ssh_hosts }}"
2022-10-27 05:43:04 +00:00
- name: Compress all SSH connections by default
blockinfile:
path: "{{ account_homedir.stdout }}/.ssh/config"
marker: "# {mark} ANSIBLE MANAGED BLOCK compression"
create: true
mode: 0600
owner: "{{ account_name.stdout }}"
group: "{{ group_name.stdout }}"
block: |
Host *
Compression yes
2022-10-27 05:43:04 +00:00
- import_tasks: tasks/peruser_freebsd.yaml
when: 'os_flavor == "freebsd"'
- import_tasks: tasks/peruser_linux.yaml
when: 'os_flavor == "linux"'