This repository has been archived on 2025-04-22. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
common-ansible/tasks/known_hosts.yml
2021-02-01 21:16:53 +01:00

39 lines
931 B
YAML

- name: load OS specific vars
include_vars: '{{ item }}'
with_first_found:
- files:
- '{{ ansible_distribution|lower }}-{{ ansible_distribution_release|lower }}.yml'
- '{{ ansible_distribution|lower }}.yml'
- '{{ ansible_os_family|lower }}.yml'
paths:
- '{{ role_path }}/vars'
- name: install packages
become: true
package:
name: '{{ item }}'
state: present
loop: '{{ known_hosts_packages }}'
- name: retrieve user $HOME
shell: 'echo $HOME'
become_user: '{{ user }}'
register: home_stats
- name: set user $HOME
set_fact:
user_home: '{{ home_stats.stdout }}'
- name: create local ssh directory
become_user: '{{ user }}'
file:
path: '{{ user_home }}/.ssh'
state: directory
mode: '0755'
- name: add items to known hosts
become_user: '{{ user }}'
known_hosts:
name: '{{ item.domain }}'
key: '{{ item.key }}'
loop: '{{ items }}'