Snippets

Green-Eye Technology Ansible playbook for automated Rancher cluster setup

Created by Shaked Klein Orbach
apiVersion: v1
kind: ConfigMap
metadata:
  name: device-config
  labels:
    {{- include "jobs.labels" . | nindent 4 }}
data:
  playbook.yaml: |
    # https://www.reddit.com/r/ansible/comments/bo8tpk/pass_a_single_ip_as_host_to_playbook/endjfft/?utm_source=reddit&utm_medium=web2x&context=3
    # ansible-playbook -i "10.1.1.3," ./playbook.yaml 
    #                                   ^ must use comma!
    - hosts: all:!localhost
      vars: 
        ansible_connection: ssh
        ansible_user: {{ .Values.localUserName }}
        ansible_ssh_pass: {{ .Values.localUserPass }}
        ansible_become_pass: {{ .Values.localUserPass }}
        ansible_python_interpreter: /usr/bin/python3
        bump_for_restart: 1
      tasks:
        - name: start ADO
          uri: 
            url: "https://dev.azure.com/NAME/PROJECT/_apis/build/builds?api-version=6.0"
            method: POST
            user: '{{ .Values.azureDevopsToken }}' #READ: https://github.com/ansible/ansible/issues/53373#issuecomment-475524546 - if username is empty, replace with password!
            password: "" #READ https://github.com/ansible/ansible/issues/53373#issuecomment-475524546 - if username is empty, replace with password!
            force_basic_auth: true
            status_code: "200"
            body_format: json
            headers:
              Content-Type: application/json
              Accept: application/json
            body: | 
              {
                  "definition": {
                      "id": {{ .Values.definitionId }}
                  },
                  "parameters":  "{\"deviceInputName\":  \"{{`{{ deviceInputName }}`}}\"}"
              }

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.