forked from MT2017055/Ansible-tower-examples
-
Notifications
You must be signed in to change notification settings - Fork 2
/
logDNA.yml
65 lines (61 loc) · 2.4 KB
/
logDNA.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
57
58
59
60
61
62
63
64
65
---
- name: installing logdna
hosts: localhost
vars:
cluster_id: "burms2dd0gn5n25d9dt0"
project_name: "ibm-observe"
secret_name: "logdna-ingestion-key"
# deployment_file_path: "https://assets.us-south.logging.cloud.ibm.com/clients/agent-resources.yaml"
zip_path: /tmp/kubeConfig-{{ cluster_id }}.zip
kube_config_path: /tmp/kubeConfig-{{ cluster_id }}
IC_IAM_TOKEN: "{{ lookup('env','IC_IAM_TOKEN') }}"
IC_IAM_REFRESH_TOKEN: "{{ lookup('env','IC_IAM_REFRESH_TOKEN') }}"
tasks:
- name: Download kubeconfig
get_url:
url: https://containers.test.cloud.ibm.com/v1/clusters/{{ cluster_id }}/config
dest: "{{ zip_path }}"
headers:
Authorization: "{{ lookup('env','IC_IAM_TOKEN') }}"
X-Auth-Refresh-Token: "{{ lookup('env','IC_IAM_REFRESH_TOKEN') }}"
- name: Delete earlier instances of kube config
file:
path: "{{ kube_config_path }}"
state: absent
- name: ansible create directory for unzip kubeconfig
file:
path: "{{ kube_config_path }}"
state: directory
- name: Unzip kube config
shell:
cmd: /usr/bin/unzip "{{ zip_path }}" -d "{{ kube_config_path }}"
- name: Read config.yaml into kube_config var
shell:
cmd: find "{{kube_config_path}}" -name "*.yml"
register: kube_config
- name: Display the kubeconfig file path
debug:
var: kube_config.stdout
- name: Create kubectl namespace
k8s:
kubeconfig: "{{ kube_config.stdout }}"
name: "{{ project_name | lower }}"
api_version: v1
kind: Namespace
state: present
- name: create injection key
k8s:
kubeconfig: "{{ kube_config.stdout }}"
state: present
api_version: v1
namespace: "{{ project_name | lower }}"
definition:
kind: Secret
metadata:
name: "{{ secret_name }}"
config_data.json: "{{ LogDNA_ingestion_key }}"
spec:
type: Opaque
- name: Deploying the LogDNA on Kubernetes cluster.
shell:
cmd: kubectl apply -f https://assets.us-south.logging.cloud.ibm.com/clients/agent-resources.yaml