-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ansible: add role to update known_hosts on windows (#3402)
Added github-windows role. based on an already existing github role. It does the same job on Windows and is used in jenkins-worker/create.yml playbook. Refs: #3265
- Loading branch information
1 parent
0468a55
commit 621e462
Showing
3 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
- hosts: | ||
- "*-win*" | ||
gather_facts: yes | ||
gather_subset: min | ||
|
||
roles: | ||
- bootstrap | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
|
||
# Set up hosts to be able to checkout/fetch from github.com via SSH. | ||
|
||
- name: Check if current user already has a .ssh directory | ||
win_stat: path='{{ansible_facts["env"]["USERPROFILE"]}}\.ssh' | ||
register: ssh_stat | ||
|
||
- name: Create a .ssh directory for current user if missing | ||
win_file: | ||
path: '{{ansible_facts["env"]["USERPROFILE"]}}\.ssh' | ||
state: directory | ||
when: not ssh_stat.stat.exists | ||
|
||
- name: Check if current user already has a known_hosts file | ||
win_stat: path='{{ansible_facts["env"]["USERPROFILE"]}}\.ssh\known_hosts' | ||
register: known_hosts_stat | ||
|
||
- name: Create a known_hosts for current user if missing | ||
win_copy: | ||
src: '../github/files/github_known_hosts' | ||
dest: '{{ansible_facts["env"]["USERPROFILE"]}}\.ssh\known_hosts' | ||
when: not known_hosts_stat.stat.exists | ||
|
||
- name: Add github known hosts to known_hosts file if present | ||
win_lineinfile: | ||
path: '{{ansible_facts["env"]["USERPROFILE"]}}\.ssh\known_hosts' | ||
line: '{{item}}' | ||
state: present | ||
loop: "{{lookup('file', '../github/files/github_known_hosts').splitlines()}}" | ||
when: known_hosts_stat.stat.exists | ||
|
||
- name: Remove github bad hosts from known_hosts file if present | ||
win_lineinfile: | ||
path: '{{ansible_facts["env"]["USERPROFILE"]}}\.ssh\known_hosts' | ||
line: '{{item}}' | ||
state: absent | ||
loop: "{{lookup('file', '../github/files/github_bad_hosts').splitlines()}}" | ||
when: known_hosts_stat.stat.exists |