Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: adding k8s module #171

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions playbooks/roles/k8s_objects/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
- name: set minishift host
block:
- name: register minishift host
shell: "{{ minishift_bin }} ip"
register: minishift_host

- name: set k8s_auth_host
set_fact:
k8s_auth_host: "https://{{ minishift_host.stdout }}:8443"
when: k8s_auth_host is not defined

- name: set auth api key if env var is set
set_fact:
k8s_auth_api_key: "{{ ansible_env.K8S_AUTH_API_KEY }}"
when: ansible_env.K8S_AUTH_API_KEY is defined

- name: Log in (obtain access token)
k8s_auth:
host: "{{ k8s_auth_host }}"
validate_certs: False
username: "{{ k8s_username }}"
password: "{{ k8s_password }}"
register: k8s_auth_results
when: k8s_username is defined and k8s_password is defined

- name: set auth api key if username/password is provided
set_fact:
k8s_auth_api_key: "{{ k8s_auth_results.k8s_auth.api_key }}"
when: k8s_auth_results.k8s_auth.api_key is defined

- name: Create openshift project
k8s:
host: "{{ k8s_auth_host }}"
api_key: "{{ k8s_auth_api_key }}"
name: "{{ PROJECT }}"
api_version: v1
kind: Project
state: present
validate_certs: false

- name: Creating k8s objects
k8s:
host: "{{ k8s_auth_host }}"
api_key: "{{ k8s_auth_api_key }}"
namespace: "{{ PROJECT }}"
state: present
validate_certs: false
definition: "{{ lookup('template', project_dir + '/' + os_template_dir + '/' + item) }}"
with_list:
"{{ k8s_resource_objects }}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does this list come from?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now it's being passed in as an --extra-var. I still need to add a vars file for this role and go through the global vars to sync it up with these changes.


8 changes: 8 additions & 0 deletions playbooks/roles/minishift/tasks/init_minishift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,12 @@
- cpu_mode_not_configured|bool
- start_minishift|bool == true

- name: set minishift host
shell: "{{ minishift_bin }} ip"
register: minishift_host

- name: set k8s_auth_host
set_fact:
k8s_auth_host: "https://{{ minishift_host.stdout }}:8443"

when: host_os == "linux"
2 changes: 1 addition & 1 deletion playbooks/setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
- role: create
- { role: prereqs, when: "run_prereqs|bool == true and setup_minishift|bool == true" }
- { role: minishift, when: "setup_minishift|bool == true" }
- { role: os_temps, when: setup_containers|bool == true }
- { role: k8s_objects }
- { role: pipeline, when: setup_pipelines|bool == true }
arilivigni marked this conversation as resolved.
Show resolved Hide resolved
- { role: playbook_hooks, when: setup_playbook_hooks|bool == true }
post_tasks:
Expand Down