-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathview_network_policy.yml
56 lines (51 loc) · 1.88 KB
/
view_network_policy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/ansible-playbook
---
#
# Copyright (c) 2018 World Wide Technology, Inc.
# All rights reserved.
#
# author: [email protected] GitHub/GitLab @joelwking
#
# description:
#
# This playbook retrieves network policy from the Tetration Network Policy Publisher
# and creates a file to view the results.
#
# usage:
#
# ./view_network_policy.yml -e "cert_directory=producer-tnp-2.cert ofile=/tmp/vnp.json"
#
#
- name: View Tetration Network Policy
hosts: localhost
connection: local
gather_facts: no
vars:
#
# These are default values which can be overridden at run time with '-e'
#
cert_directory: producer-tnp-2.cert # directory name of tetration certificates
validate_certs: 'no' # certificate verify
ofile: '{{ playbook_dir }}/files/view_network_policy.json'
tasks:
- name: Select broker IP
# Depending on the type of Tetration, there can be one or more available Kafka brokers, select one.
# The input file could either contain '192.0.2.1:443' or '192.0.2.1:443,192.0.2.2:443,192.0.2.3:443'
set_fact:
kafka_broker: '{{ item }}'
with_random_choice: "{{ lookup('file', '{{ playbook_dir }}/files/certificates/{{ cert_directory }}/kafkaBrokerIps.txt').split(',') }}"
- name: Tetration Network Policy
tetration_network_policy:
broker: '{{ kafka_broker }}'
topic: "{{ lookup('file', '{{ playbook_dir }}/files/certificates/{{ cert_directory }}/topic.txt') }}"
cert_directory: "{{ playbook_dir }}/files/certificates/{{ cert_directory }}/"
validate_certs: '{{ validate_certs }}'
timeout: 62000
# start_at: earliest
# start_at_offset: 43271
register: tnp
- name: Write the policy to a file
copy:
content: '{{ tnp }}'
dest: '{{ ofile }}'
mode: 0644