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.
77 lines
2.6 KiB
77 lines
2.6 KiB
|
|
---
|
|
- name: Get the default ipv4 address
|
|
set_fact:
|
|
besu_default_ip: >-
|
|
{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] if
|
|
hostvars[inventory_hostname]['ansible_default_ipv4']['address'] is
|
|
defined else '127.0.0.1' }}
|
|
besu_aws_private_ip: ""
|
|
besu_gcp_private_ip: ""
|
|
besu_azure_private_ip: ""
|
|
|
|
- name: Check if running on AWS
|
|
uri:
|
|
url: http://169.254.169.254/latest/meta-data/local-ipv4
|
|
method: GET
|
|
return_content: yes
|
|
status_code: 200
|
|
register: aws_private_ip_output
|
|
ignore_errors: True
|
|
when: (besu_plugin_fleet_node_role=="FOLLOWER")
|
|
|
|
- name: Set the host ip if we are in AWS
|
|
set_fact:
|
|
besu_plugin_fleet_follower_http_host: "{{ aws_private_ip_output.content }}"
|
|
when: (besu_plugin_fleet_node_role=="FOLLOWER") and
|
|
(aws_private_ip_output.status == 200)
|
|
|
|
- name: Check if running on Azure
|
|
uri:
|
|
url: http://169.254.169.254/metadata/instance/network/interface/0/ipv4/ipAddress/0/privateIpAddress?api-version=2017-08-01&format=text
|
|
method: GET
|
|
headers:
|
|
Metadata: true
|
|
return_content: yes
|
|
status_code: 200
|
|
register: azure_private_ip_output
|
|
ignore_errors: True
|
|
when: (besu_plugin_fleet_node_role=="FOLLOWER") and
|
|
( aws_private_ip_output.status != 200 )
|
|
|
|
- name: Set the host ip if we are in Azure
|
|
set_fact:
|
|
besu_plugin_fleet_follower_http_host: "{{ azure_private_ip_output.content }}"
|
|
when: (besu_plugin_fleet_node_role=="FOLLOWER") and
|
|
( aws_private_ip_output.status != 200 ) and
|
|
( azure_private_ip_output.status == 200 )
|
|
|
|
- name: Check if running on GCP
|
|
uri:
|
|
url: http://169.254.169.254/computeMetadata/v1/instance/network-interfaces/0/access-configs/0/ip
|
|
method: GET
|
|
headers:
|
|
Metadata-Flavor: Google
|
|
return_content: yes
|
|
status_code: 200
|
|
register: gcp_private_ip_output
|
|
ignore_errors: True
|
|
when: (besu_plugin_fleet_node_role=="FOLLOWER") and
|
|
( aws_private_ip_output.status != 200 ) and
|
|
( azure_private_ip_output.status != 200 )
|
|
|
|
- name: Set the host ip if we are in GCP
|
|
set_fact:
|
|
besu_plugin_fleet_follower_http_host: "{{ gcp_private_ip_output.content }}"
|
|
when: (besu_plugin_fleet_node_role=="FOLLOWER") and
|
|
( aws_private_ip_output.status != 200 ) and
|
|
( azure_private_ip_output.status != 200 ) and
|
|
( gcp_private_ip_output == 200 )
|
|
|
|
- name: Fallback to the ansible default ip
|
|
set_fact:
|
|
besu_plugin_fleet_follower_http_host: "{{ besu_default_ip }}"
|
|
when: (besu_plugin_fleet_node_role=="FOLLOWER") and
|
|
( aws_private_ip_output.status != 200 ) and
|
|
( azure_private_ip_output.status != 200 ) and
|
|
( gcp_private_ip_output != 200 )
|
|
|