Skip to content

Instantly share code, notes, and snippets.

@AkashRajvanshi
Last active September 22, 2020 15:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AkashRajvanshi/7ea07ebaf4b6c56f568938c72184c816 to your computer and use it in GitHub Desktop.
Save AkashRajvanshi/7ea07ebaf4b6c56f568938c72184c816 to your computer and use it in GitHub Desktop.
- name: Setup Kubernetes with Ansible
hosts: cluster
become: True
tasks:
- name: Updating the system
apt: update_cache=yes force_apt_get=yes cache_valid_time=3600
- name: Installing Snap
apt: name=snapd state=latest
- name: Installing MicroK8s Snap Package
snap:
name: microk8s
channel: 1.19
classic: yes
- name: Adding vagrant user to microk8s group
user:
name: "{{ ansible_user }}"
groups: microk8s
append: yes
become: yes
- name: Giving vagrant user a permission to ~/.kube directory
file:
path: ~/.kube
owner: "{{ ansible_user }}"
group: "{{ ansible_user }}"
mode: 0775
state: directory
recurse: yes
- shell: microk8s.kubectl get nodes
register: shell_result
- debug:
var: shell_result.stdout_lines
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment