2016-12-09 17:38:17 +08:00
|
|
|
---
|
2021-03-26 15:48:43 +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
|
|
|
|
|
|
|
- name: create ssh bastion conf
|
|
|
|
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:
|
|
|
|
src: ssh-bastion.conf
|
|
|
|
dest: "{{ playbook_dir }}/ssh-bastion.conf"
|
2021-07-12 15:00:47 +08:00
|
|
|
mode: 0640
|