---
- name: Do not accept locale environment variables passed over SSH.
  lineinfile:
    dest: /etc/ssh/sshd_config
    regexp: "^AcceptEnv LANG"
    state: absent
    validate: "/usr/sbin/sshd -T -f %s"

- name: Check if local known_hosts file is present.
  stat: "path={{ known_hosts_path | default('~/.ssh/known_hosts') }}"
  register: known_hosts_file
  connection: local
  become: no

- name: Copy known_hosts file from host into Drupal VM.
  copy:
    src: "{{ known_hosts_path | default('~/.ssh/known_hosts') }}"
    dest: ~/.ssh/known_hosts
    mode: 0644
  become: no
  when: known_hosts_file.stat.exists

- name: Set SSH home directory.
  lineinfile:
    dest: "/home/{{ drupalvm_user }}/.bashrc"
    state: present
    create: yes
    regexp: "^SSH_HOME="
    line: "SSH_HOME={{ ssh_home }} && [ -e $SSH_HOME ] && cd $SSH_HOME"
  become: no
  when: ssh_home is defined
