google.cloud/roles/gcp_http_lb/tasks/main.yml

65 lines
2.5 KiB
YAML

---
- name: Create a global address for the load balancer.
google.cloud.gcp_compute_global_address:
name: "{{ gcp_http_lb_globaladdress }}"
project: "{{ gcp_http_lb_gcp_project }}"
auth_kind: "{{ gcp_http_lb_auth_kind }}"
service_account_file: "{{ gcp_http_lb_service_account_file }}"
state: "{{ gcp_http_lb_state }}"
register: globaladdress
- name: Create a http health check to verify lb working
google.cloud.gcp_compute_http_health_check:
name: "{{ gcp_http_lb_healthcheck }}"
healthy_threshold: 10
port: 80
timeout_sec: 2
unhealthy_threshold: 5
project: "{{ gcp_http_lb_gcp_project }}"
auth_kind: "{{ gcp_http_lb_auth_kind }}"
service_account_file: "{{ gcp_http_lb_service_account_file }}"
state: "{{ gcp_http_lb_state }}"
register: healthcheck
- name: Create a backend service
google.cloud.gcp_compute_backend_service:
name: "{{ gcp_http_lb_backendservice }}"
backends:
- group: "{{ gcp_http_lb_backend.selfLink }}"
health_checks:
- "{{ healthcheck.selfLink }}"
enable_cdn: "{{ gcp_http_lb_cdn }}"
project: "{{ gcp_http_lb_gcp_project }}"
auth_kind: "{{ gcp_http_lb_auth_kind }}"
service_account_file: "{{ gcp_http_lb_service_account_file }}"
state: "{{ gcp_http_lb_state }}"
register: backendservice
- name: Create a url map
google.cloud.gcp_compute_url_map:
name: "{{ gcp_http_lb_urlmap }}"
default_service: "{{ backendservice }}"
project: "{{ gcp_http_lb_gcp_project }}"
auth_kind: "{{ gcp_http_lb_auth_kind }}"
service_account_file: "{{ gcp_http_lb_service_account_file }}"
state: "{{ gcp_http_lb_state }}"
register: urlmap
- name: Create a target http proxy
google.cloud.gcp_compute_target_http_proxy:
name: "{{ gcp_http_lb_httpproxy }}"
url_map: "{{ urlmap }}"
project: "{{ gcp_http_lb_gcp_project }}"
auth_kind: "{{ gcp_http_lb_auth_kind }}"
service_account_file: "{{ gcp_http_lb_service_account_file }}"
state: "{{ gcp_http_lb_state }}"
register: httpproxy
- name: Create a global forwarding rule
google.cloud.gcp_compute_global_forwarding_rule:
name: "{{ gcp_http_lb_forwardingrule }}"
ip_address: "{{ globaladdress.address }}"
load_balancing_scheme: EXTERNAL
ip_protocol: TCP
port_range: 80-80
target: "{{ httpproxy.selfLink }}"
project: "{{ gcp_http_lb_gcp_project }}"
auth_kind: "{{ gcp_http_lb_auth_kind }}"
service_account_file: "{{ gcp_http_lb_service_account_file }}"
state: "{{ gcp_http_lb_state }}"
register: result