Skip to content

Commit

Permalink
build: add option for masked config builds (w/o secrets)
Browse files Browse the repository at this point in the history
  • Loading branch information
liske committed Feb 25, 2024
1 parent b850c68 commit fd0eacf
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
9 changes: 9 additions & 0 deletions hosts/host_vars/localhost/ixp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
build_masked: false

secrets_masked:
eos:
admin_hash: "{MASKED}"
deploy_hash: "{MASKED}"
snmp_community: "{MASKED}"
radius_key: "{MASKED}"
root_pubkey: "{MASKED}"
7 changes: 6 additions & 1 deletion roles/bird_build/tasks/client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
- name: set md5 secret
ansible.builtin.set_fact:
client2: "{{ client2|combine({ 'password': peer[family + 'bgpmd5secret']}, recursive=true) }}"
when: peer[family + 'bgpmd5secret'] != None
when: peer[family + 'bgpmd5secret'] != None and not build_masked

- name: mask md5 secret
ansible.builtin.set_fact:
client2: "{{ client2|combine({ 'password': '{MASKED}'}, recursive=true) }}"
when: peer[family + 'bgpmd5secret'] != None and build_masked

- ansible.builtin.set_fact:
ddix_peers: "{{ ddix_peers + [client2] }}"
2 changes: 1 addition & 1 deletion roles/bird_build/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
dest: "{{ arouteserver_workdir }}/dist/clients.yml"

- name: run arouteserver bird
ansible.builtin.shell: arouteserver bird --cfg arouteserver/arouteserver.yml --clients "{{ arouteserver_workdir }}/dist/clients.yml" -o "{{ arouteserver_workdir }}/dist/bird.conf" --cache-dir "{{ arouteserver_workdir }}/cache" --use-local-files logging
ansible.builtin.shell: arouteserver bird --cfg arouteserver/arouteserver.yml --clients "{{ arouteserver_workdir }}/dist/clients.yml" -o "{{ arouteserver_workdir }}/dist/bird{% if build_masked %}.masked{% endif %}.conf" --cache-dir "{{ arouteserver_workdir }}/cache" --use-local-files logging
args:
chdir: "{{ playbook_dir }}/.."
environment:
Expand Down
5 changes: 5 additions & 0 deletions roles/com_secrets/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
- name: parse secrets
ansible.builtin.set_fact:
secrets: "{{ lookup('ansible.builtin.file', lookup('ansible.builtin.env', 'AROUTESERVER_SECRETS_FILE', default=(playbook_dir + '/../secrets.yml')))|from_yaml }}"

- name: mask secrets
ansible.builtin.set_fact:
secrets: "{{ secrets|combine(secrets_masked) }}"
when: build_masked
2 changes: 1 addition & 1 deletion roles/eos_build/tasks/eos.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- name: build eos config
ansible.builtin.template:
src: "{{ playbook_dir }}/../templates/eos/{{ switch_fqdn }}.conf.j2"
dest: "{{ arouteserver_workdir }}/eos/{{ switch_fqdn }}.conf"
dest: "{{ arouteserver_workdir }}/eos/{{ switch_fqdn }}{% if build_masked %}.masked{% endif %}.conf"

0 comments on commit fd0eacf

Please sign in to comment.