- name: load vars, if needed ansible.builtin.include_vars: "{{ item }}" loop: - "{{ role_path }}/vars/default.yml" - "{{ role_path }}/vars/{{ ansible_facts.distribution }}.yml" - "{{ role_path }}/vars/{{ ansible_facts.distribution }}_{{ ansible_facts.distribution_major_version }}.yml" when: item is file - name: remove cloud-init become: true ansible.builtin.package: name: cloud-init state: absent when: ansible_facts.pkg_mgr not in ['atomic_container'] - name: create .ssh directory ansible.builtin.file: path: "{{ ansible_user_dir }}/.ssh" state: directory mode: "0700" - name: fetch authorized_keys ansible.builtin.get_url: mode: "0600" dest: "{{ ansible_user_dir }}/.ssh/authorized_keys" url: https://raw.githubusercontent.com/hashicorp/vagrant/master/keys/vagrant.pub register: _fetch_authorized_keys retries: 3 until: _fetch_authorized_keys is success - name: Sudo commands block: - name: configure sshd ansible.builtin.lineinfile: line: UseDNS no path: /etc/ssh/sshd_config - name: check for the sshd_config.d directory ansible.builtin.stat: path: /etc/ssh/sshd_config.d register: _vagrant_sshd_config_d - name: be sure that sshd is configured properly to accept the pubkey ansible.builtin.copy: content: PubkeyAcceptedKeyTypes +ssh-rsa mode: "0600" owner: root group: root dest: /etc/ssh/sshd_config.d/00-vagrant_accept_pubkey.conf when: _vagrant_sshd_config_d.stat.exists - name: enable sshd ansible.builtin.service: name: "{{ vagrant_ssh_service_name }}" state: started enabled: true # Fedora 31 has a bug in systemd with kernel >= 5.8 that makes us # unable to determine state of the service. However, if we were able # to connect to it to run this Ansible, then we clearly are up # and running and we can safely ignore this error # noqa ignore-errors ignore_errors: >- {{ ansible_facts.distribution == 'Fedora' and ansible_facts.distribution_major_version == '31' }} become: true