-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path00_new-project.yaml
More file actions
41 lines (32 loc) · 1.03 KB
/
00_new-project.yaml
File metadata and controls
41 lines (32 loc) · 1.03 KB
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
---
- name: Create OpenShift Project hello-world
hosts: localhost
connection: local
gather_facts: false
vars:
kubeconfig_path: "/root/ocp4/auth/kubeconfig"
project_name: "hello-world"
tasks:
- name: Create a new project/namespace
k8s:
kubeconfig: "{{ kubeconfig_path }}"
state: present
definition:
apiVersion: v1
kind: Namespace
metadata:
name: "{{ project_name }}"
- name: Verify the project was created
k8s_info:
kubeconfig: "{{ kubeconfig_path }}"
kind: Namespace
register: ns_info
- name: Show namespaces
debug:
msg: "{{ ns_info.resources | map(attribute='metadata') | map(attribute='name') | list }}"
- name: Show only the created namespace
command: "oc get namespaces -o jsonpath='{.items[*].metadata.name}'"
register: ns_output
- name: Filter for hello-world namespace
debug:
msg: "created: {{ ns_output.stdout.split() | select('equalto', 'hello-world') | list }}"