You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
931 B

  1. ---
  2. - name: Set bastion host IP and port
  3. set_fact:
  4. bastion_ip: "{{ hostvars[groups['bastion'][0]]['ansible_host'] | d(hostvars[groups['bastion'][0]]['ansible_ssh_host']) }}"
  5. bastion_port: "{{ hostvars[groups['bastion'][0]]['ansible_port'] | d(hostvars[groups['bastion'][0]]['ansible_ssh_port']) | d(22) }}"
  6. delegate_to: localhost
  7. connection: local
  8. # As we are actually running on localhost, the ansible_ssh_user is your local user when you try to use it directly
  9. # To figure out the real ssh user, we delegate this task to the bastion and store the ansible_user in real_user
  10. - name: Store the current ansible_user in the real_user fact
  11. set_fact:
  12. real_user: "{{ ansible_user }}"
  13. - name: Create ssh bastion conf
  14. become: false
  15. delegate_to: localhost
  16. connection: local
  17. template:
  18. src: "{{ ssh_bastion_confing__name }}.j2"
  19. dest: "{{ playbook_dir }}/{{ ssh_bastion_confing__name }}"
  20. mode: "0640"