Skip to content

Instantly share code, notes, and snippets.

@socketwench
Created June 22, 2021 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save socketwench/80e79d68f2970d51de0388d889726050 to your computer and use it in GitHub Desktop.
Save socketwench/80e79d68f2970d51de0388d889726050 to your computer and use it in GitHub Desktop.
Flight Deck Cluster ingress with HTTPAuth
---
- hosts: stage
vars:
flightdeck_cluster:
namespace: "example-com"
secrets:
- name: "ingress-auth"
data:
- name: "auth"
value: "{{ lookup('file', _run_temp_dir.path + '/.htpasswd' )}}"
ingress:
name: "ingress"
auth:
secret: "ingress-auth"
rules:
- host: "example.com"
paths:
- path: "/"
backend: "web"
port: "6081"
tasks:
- name: Create a temp directory to store files needed by the run
tempfile:
state: directory
prefix: "ansible-deploy-{{ cluster_name }}"
register: _run_temp_dir
notify:
- delete temp items
- name: Get the kubeconfig file.
import_role:
name: ten7.digitalocean_kubeconfig
vars:
digitalocean_kubeconfig:
cluster: "{{ cluster_name }}"
kubeconfig: "{{ _run_temp_dir.path }}/kubectl.yaml"
- name: Generate an .htpasswd to file as Ansible can't do this to a var
htpasswd:
path: "{{ _run_temp_dir.path }}/.htpasswd"
state: present
name: "{{ item.user }}"
password: "{{ item.pass }}"
loop:
- user: "myusername"
pass: "mypassword"
- name: Deploy the cluster definitions
include_role:
name: "ten7.flightdeck_cluster"
vars:
flightdeck_cluster_kubeconfig: "{{ _run_temp_dir.path }}/kubectl.yaml"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment