Outils pour utilisateurs

Outils du site


tech:ansible_uri_-_tower_api

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Prochaine révision
Révision précédente
tech:ansible_uri_-_tower_api [2025/03/24 15:06] – créée - modification externe 127.0.0.1tech:ansible_uri_-_tower_api [2026/06/07 19:12] (Version actuelle) – modification externe 127.0.0.1
Ligne 1: Ligne 1:
 +<!DOCTYPE markdown>
 +{{tag>Ansible CA}}
 +
 +# Ansible uri - Tower API
 +
 +Avec curl
 +~~~bash
 +curl -k -u username:'P@ssw0rd' -H 'Content-Type: application/json' -X GET https://tower.acme.fr/api/v2/job_templates/93/launch/ -d '
 +{
 +    "extra_vars": {
 +        "git_path": "/project/plop",
 +        "git_user": "gittoken"
 +    }
 +}'
 +~~~
 +
 +Via Ansible
 +~~~yaml
 +#!/usr/bin/env ansible-playbook
 +---
 +
 +- hosts: localhost
 +
 +  tasks:
 +    - name: call api
 +      register: plop
 +      uri:
 +        url: https://tower.acme.fr/api/v2/job_templates/93/launch/
 +        method: POST
 +        force: true
 +        force_basic_auth: true
 +        user: username
 +        password: 'P@ssw0rd'
 +        validate_certs: false
 +        # body_format: form-urlencoded
 +        body_format: json
 +        headers:
 +          Content-Type: "application/json"
 +        body: |
 +          {
 +              "extra_vars": {
 +                  "git_path": "/project/plop",
 +                  "git_user": "gittoken"
 +              }
 +          }
 +        status_code: 201
 +
 +    - name: DEBUG 10
 +      debug: var=plop
 +~~~
 +
 +Ou encore 
 +
 +~~~yaml
 +#!/usr/bin/env ansible-playbook
 +---
 +
 +- hosts: localhost
 +
 +  tasks:
 +    - name: call api
 +      register: plop
 +      uri:
 +        url: https://tower.acme.fr/api/v2/job_templates/93/launch/
 +        method: POST
 +        force: true
 +        force_basic_auth: true
 +        user: username
 +        password: 'P@ssw0rd'
 +        validate_certs: false
 +        body_format: json
 +        headers:
 +          Content-Type: "application/json"
 +        src: plop.json
 +        status_code: 201
 +~~~
 +
 +`plop.json`
 +~~~javascript
 +          {
 +              "extra_vars": {
 +                  "git_path": "/project/plop",
 +                  "git_user": "gittoken"
 +              }
 +          }
 +~~~
 +
 +
 +## Pb
 +
 +### Pb de logs tronqués
 +
 +Consulter la sortie : https://<tower-FQDN>/api/v2/job_templates/<job-template-id>/  
 +
 +
  

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki