Skip to content
This repository was archived by the owner on Oct 15, 2020. It is now read-only.

Commit 71b4514

Browse files
duck-rhmscherer
authored andcommitted
generate SSH config
1 parent 8aff5aa commit 71b4514

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

meta/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ galaxy_info:
44
description: Auto builder for middleman based static website, deployed by OSAS
55
company: Red Hat
66
license: MIT
7-
min_ansible_version: 1.8
7+
min_ansible_version: 2.3
88
# Only tested with Fedora, since that's what
99
# glesage is running, but it likely work everywhere, and
1010
# would be ok to get patches and/or help people to port it

tasks/main.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,37 @@
9797
delegate_to: "{{ rsync_server }}"
9898
remote_user: "{{ rsync_user }}"
9999
when: rsync_server is defined and rsync_location is defined and rsync_user is defined
100+
101+
- name: Compute SSH config for rsync sync
102+
set_fact:
103+
remote_user: "{{ rsync_user }}"
104+
remote_host: "{{ rsync_server }}"
105+
when: rsync_url
106+
107+
- name: Compute SSH config for openshift sync
108+
block:
109+
- name: Fetch site configuration
110+
slurp:
111+
src: "/srv/builder/{{ name }}/data/site.yml"
112+
register: site_raw
113+
- name: Parse site configuration
114+
set_fact:
115+
site: "{{ site_raw['content'] | b64decode | from_yaml }}"
116+
- name: Get OpenShift sync
117+
set_fact:
118+
# seen pattern: <user>@<host> or ssh://<user>@<host>/<path>
119+
remote_user: "{{ site.openshift | regex_replace('^.*?([^/]+)@.*$', '\\1') }}"
120+
remote_host: "{{ site.openshift | regex_replace('^.*@([^/]+).*$', '\\1') }}"
121+
when: not rsync_url
122+
123+
- name: Create SSH config
124+
blockinfile:
125+
path: /srv/builder/.ssh/config
126+
owner: "{{ builder_username }}"
127+
group: "{{ builder_username }}"
128+
block: |
129+
Match Host {{ remote_host }} User {{ remote_user }}
130+
IdentityFile /srv/builder/.ssh/{{ name }}_id.rsa
131+
marker: "# {mark} ANSIBLE MANAGED BLOCK {{ name }}"
132+
create: true
133+

0 commit comments

Comments
 (0)