2016-12-09 09:38:17 +00:00
|
|
|
---
|
2021-03-26 07:48:43 +00:00
|
|
|
- name: set bastion host IP and port
|
2019-05-16 07:27:43 +00:00
|
|
|
set_fact:
|
2018-10-10 02:14:33 +00:00
|
|
|
bastion_ip: "{{ hostvars[groups['bastion'][0]]['ansible_host'] | d(hostvars[groups['bastion'][0]]['ansible_ssh_host']) }}"
|
2021-03-26 07:48:43 +00:00
|
|
|
bastion_port: "{{ hostvars[groups['bastion'][0]]['ansible_port'] | d(hostvars[groups['bastion'][0]]['ansible_ssh_port']) | d(22) }}"
|
2018-10-10 02:14:33 +00:00
|
|
|
delegate_to: localhost
|
2020-06-25 15:14:38 +00:00
|
|
|
connection: local
|
2016-12-09 09:38:17 +00:00
|
|
|
|
|
|
|
# As we are actually running on localhost, the ansible_ssh_user is your local user when you try to use it directly
|
2017-10-14 08:52:40 +00:00
|
|
|
# To figure out the real ssh user, we delegate this task to the bastion and store the ansible_user in real_user
|
2019-05-16 07:27:43 +00:00
|
|
|
- name: Store the current ansible_user in the real_user fact
|
|
|
|
set_fact:
|
2017-10-14 08:52:40 +00:00
|
|
|
real_user: "{{ ansible_user }}"
|
2016-12-09 09:38:17 +00:00
|
|
|
|
|
|
|
- name: create ssh bastion conf
|
|
|
|
become: false
|
2018-10-10 02:14:33 +00:00
|
|
|
delegate_to: localhost
|
2020-06-25 15:14:38 +00:00
|
|
|
connection: local
|
2017-02-17 21:22:34 +00:00
|
|
|
template:
|
|
|
|
src: ssh-bastion.conf
|
|
|
|
dest: "{{ playbook_dir }}/ssh-bastion.conf"
|