Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow content of SSH key to be defined through a variable #10

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ None
* `autossh_tunnel_client_autossh_pidfile`: [default: `/var/run/autossh/autossh-tunnel-client.pid`]: Write pid to specified file
* `autossh_tunnel_client_autossh_poll`: [default: `60`]: Specifies the connection poll time in seconds

* `autossh_tunnel_client_key_map`: [default: `[]`]: SSH key declarations
* `autossh_tunnel_client_key_map.{n}.src`: [required]: The local path of the file to copy, can be absolute or relative (e.g. `../../../files/autossh-tunnel-client/etc/autossh/id_rsa`)
* `autossh_tunnel_client_key_map`: [default: `[]`]: SSH key declarations. Each requires either `src` or `content` to be set (mutually exclusive)
* `autossh_tunnel_client_key_map.{n}.src`: [optional]: The path of the file to copy, can be absolute or relative (e.g. `../../../files/autossh-tunnel-client/etc/autossh/id_rsa`)
* `autossh_tunnel_client_key_map.{n}.remote_src`: [optional, default `false`]: Whether the `src` is on the remote
* `autossh_tunnel_client_key_map.{n}.content`: [optional]: The key content. Must be used with `dest`
* `autossh_tunnel_client_key_map.{n}.dest`: [optional, default `src | basename`]: The remote path of the file to copy, relative to `/etc/autossh` (e.g. `id_rsa`)
* `autossh_tunnel_client_key_map.{n}.owner`: [optional, default `root`]: The name of the user that should own the file
* `autossh_tunnel_client_key_map.{n}.group`: [optional, default `owner`, `root`]: The name of the group that should own the file
Expand Down
6 changes: 4 additions & 2 deletions tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@

- name: configure | copy key file(s)
ansible.builtin.copy:
src: "{{ item.src }}"
src: "{{ item.src | default(omit) }}"
remote_src: "{{ item.remote_src | default(omit) }}"
dest: "{{ autossh_tunnel_client_configuration_directory }}/{{ item.dest | default(item.src | basename) }}"
content: "{{ item.content | default(omit) }}"
# Even when `item.dest` is defined, the argument for the alternative default is evaluated so needs to not fail when `item.src` is not defined
dest: "{{ autossh_tunnel_client_configuration_directory }}/{{ item.dest | default(item.src | default('id_rsa') | basename) }}"
owner: "{{ item.owner | default('root') }}"
group: "{{ item.group | default(item.owner) | default('root') }}"
mode: "{{ item.mode | default('0600') }}"
Expand Down