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

Commit 6f824bc

Browse files
committed
generate SSH config
1 parent 63ced63 commit 6f824bc

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
@@ -90,3 +90,37 @@
9090
delegate_to: "{{ rsync_server }}"
9191
remote_user: "{{ rsync_user }}"
9292
when: rsync_server is defined and rsync_location is defined and rsync_user is defined
93+
94+
- name: Compute SSH config for rsync sync
95+
set_fact:
96+
remote_user: "{{ rsync_user }}"
97+
remote_host: "{{ rsync_server }}"
98+
when: rsync_url
99+
100+
- name: Compute SSH config for openshift sync
101+
block:
102+
- name: Fetch site configuration
103+
slurp:
104+
src: "/srv/builder/{{ name }}/data/site.yml"
105+
register: site_raw
106+
- name: Parse site configuration
107+
set_fact:
108+
site: "{{ site_raw['content'] | b64decode | from_yaml }}"
109+
- name: Get OpenShift sync
110+
set_fact:
111+
# seen pattern: <user>@<host> or ssh://<user>@<host>/<path>
112+
remote_user: "{{ site.openshift | regex_replace('^.*?([^/]+)@.*$', '\\1') }}"
113+
remote_host: "{{ site.openshift | regex_replace('^.*@([^/]+).*$', '\\1') }}"
114+
when: not rsync_url
115+
116+
- name: Create SSH config
117+
blockinfile:
118+
path: /srv/builder/.ssh/config
119+
owner: "{{ builder_username }}"
120+
group: "{{ builder_username }}"
121+
block: |
122+
Match Host {{ remote_host }} User {{ remote_user }}
123+
IdentityFile /srv/builder/.ssh/{{ name }}_id.rsa
124+
marker: "# {mark} ANSIBLE MANAGED BLOCK {{ name }}"
125+
create: true
126+

0 commit comments

Comments
 (0)