Create your first MastJob (Hello World)
This is the time when you should create your first MastJob. So yes, this is beloved 'Hello World'.
Before you get dirty with code, remember to install mast in your cluster and set your current namespace to mast
First things firsts, all actions on cluster at the very end are executed by Ansible. You need to create a playbook to print our 'Hello world' message.
The playbook looks like this:
playbook.yaml
- hosts: localhost
tasks:
- name: Hello from ansible inside your cluster
debug:
msg: "Hello world"
To make this playbook possible to use in cluster, you have to add it as a ConfigMap.
playbook-configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: hello-world-playbook
data:
playbook.yaml: |
- hosts: localhost
tasks:
- name: Hello from ansible inside your cluster
debug:
msg: "Hello there"
Now is the time to write your first MastJob.
hello-world-mastjob.yaml
apiVersion: mast.ansi.services/v1
kind: MastJob
metadata:
name: hello-world
namespace: mast
spec:
ansible:
version: latest
configuration: #
playbook: #
- fromConfigMap: #
name: hello-world-playbook
key: playbook.yaml
Add your MastJob to cluster with mast
CLI or kubectl
.
The last step is to run this MastJob. You can do it with Mast CLI
Or by submitting MastRun file withkubectl
:
hello-world-mastrun.yaml
apiVersion: mast.ansi.services/v1
kind: MastRun
metadata:
name: helo-world
namespace: mast
spec:
mastJobRef:
name: hello-world
Use mast run list
to check wheather MastRun is being executed and mast run logs
to see your message.