2016-12-09 17:38:17 +08:00
|
|
|
---
|
2023-07-26 22:36:22 +08:00
|
|
|
- name: Set bastion host IP and port
|
2019-05-16 15:27:43 +08:00
|
|
|
set_fact:
|
2018-10-10 10:14:33 +08:00
|
|
|
bastion_ip: "{{ hostvars[groups['bastion'][0]]['ansible_host'] | d(hostvars[groups['bastion'][0]]['ansible_ssh_host']) }}"
|
2021-03-26 15:48:43 +08:00
|
|
|
bastion_port: "{{ hostvars[groups['bastion'][0]]['ansible_port'] | d(hostvars[groups['bastion'][0]]['ansible_ssh_port']) | d(22) }}"
|
2018-10-10 10:14:33 +08:00
|
|
|
delegate_to: localhost
|
2020-06-25 23:14:38 +08:00
|
|
|
connection: local
|
2016-12-09 17:38:17 +08: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 16:52:40 +08: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 15:27:43 +08:00
|
|
|
- name: Store the current ansible_user in the real_user fact
|
|
|
|
set_fact:
|
2017-10-14 16:52:40 +08:00
|
|
|
real_user: "{{ ansible_user }}"
|
2016-12-09 17:38:17 +08:00
|
|
|
|
2023-07-26 22:36:22 +08:00
|
|
|
- name: Create ssh bastion conf
|
2016-12-09 17:38:17 +08:00
|
|
|
become: false
|
2018-10-10 10:14:33 +08:00
|
|
|
delegate_to: localhost
|
2020-06-25 23:14:38 +08:00
|
|
|
connection: local
|
2017-02-18 05:22:34 +08:00
|
|
|
template:
|
2021-10-15 09:46:54 +08:00
|
|
|
src: "{{ ssh_bastion_confing__name }}.j2"
|
|
|
|
dest: "{{ playbook_dir }}/{{ ssh_bastion_confing__name }}"
|
2021-07-12 15:00:47 +08:00
|
|
|
mode: 0640
|