Semaphore via Ansible Playbook
Examples of triggering REST API GET and POST requests via Ansible
---
- hosts: localhost
gather_facts: no
tasks:
- name: Get list of projects
ansible.builtin.uri:
url: http://10.10.10.10:3001/api/projects
method: GET
status_code: 200
body_format: json
headers:
Authorization: "Bearer elqwh13hxky3oi_atbpdax7engry6nwwp2wwcp3g6ng="
# register: output
- name: Get list of all runs
ansible.builtin.uri:
url: http://10.10.10.10:3001/api/project/1/tasks/last
method: GET
status_code: 200
body_format: json
headers:
Authorization: "Bearer elqwh13hxky3oi_atbpdax7engry6nwwp2wwcp3g6ng="
register: output
# tags: now
- name: Create new project
ansible.builtin.uri:
url: http://10.10.10.10:3001/api/projects
method: POST
status_code: 201
body_format: json
headers:
Authorization: "Bearer elqwh13hxky3oi_atbpdax7engry6nwwp2wwcp3g6ng="
body:
name: REST-API-creation1
alert: false
register: output
tags: now
- name: Print value
debug:
var: output