65 lines
1.6 KiB
YAML
65 lines
1.6 KiB
YAML
---
|
|
# - name: Check sshwifty_* variables are not empty
|
|
# assert:
|
|
# that:
|
|
# sshwifty_configuration_directory
|
|
# sshwifty_hostname
|
|
# sshwifty_public_port
|
|
# sshwifty_shared_key
|
|
# sshwifty_authentication
|
|
# sshwifty_ssh_password
|
|
# sshwifty_ssh_user
|
|
# sshwifty_internal_port
|
|
# sshwifty_configuration_directory
|
|
# sshwifty_work_directory
|
|
# sshwifty_gateway_access
|
|
# msg: ""
|
|
|
|
- name: Install required system packages
|
|
ansible.builtin.apt:
|
|
name:
|
|
- vim
|
|
state: latest
|
|
update_cache: true
|
|
|
|
- name: Create SSHwifty configuration directory
|
|
file:
|
|
path: "{{ sshwifty_configuration_directory }}"
|
|
state: directory
|
|
|
|
- name: Scan SSH keys
|
|
shell: "ssh-keyscan -t ed25519 {{ hostvars[item]['ansible_facts']['default_ipv4']['address'] }} 2>/dev/null | ssh-keygen -lf - |cut -f2 -d' '"
|
|
register: "host_keys"
|
|
changed_when: false
|
|
with_items: "{{ groups['role_mongo'] }}"
|
|
|
|
- debug:
|
|
msg: "item.item={{ item.item }}, item.stdout={{ item.stdout }}"
|
|
with_items: "{{ host_keys.results }}"
|
|
|
|
- name: Deploy SSHwifty configuration
|
|
template:
|
|
src: templates/sshwifty.conf.j2
|
|
dest: "{{ sshwifty_configuration_directory }}/sshwifty.conf"
|
|
|
|
# - name: Debug
|
|
# fail: "msg=STOP"
|
|
# when: "True"
|
|
|
|
- name: Create SSHwifty directory
|
|
file:
|
|
path: "{{ sshwifty_work_directory }}"
|
|
state: directory
|
|
|
|
- name: Deploy SSHwifty configuration
|
|
template:
|
|
src: templates/docker-compose.yml.j2
|
|
dest: "{{ sshwifty_work_directory }}/docker-compose.yml"
|
|
|
|
- name: Run SSHwifty
|
|
community.docker.docker_compose:
|
|
project_src: "{{ sshwifty_work_directory }}"
|
|
recreate: always
|
|
state: present
|
|
|
|
#
|