AWX and PHP via API

0

I wanted to know if there is any way to have the following structure:

  • An ansx awx server with playbooks already inserted.
  • A web environment that accesses this awx server through an api.
  • Is it possible for this connection to be made by php through a key to access an awx server to execute jobs?

        
    asked by Ivheror 27.11.2018 в 15:05
    source

    1 answer

    1

    First you must make a POST call to this endpoint / api / v1 / authtoken /

    Passing you username and password:

    content-type: application / json body: {"username": "user", "password": "my pass"}

    This returns a token:

    {     "token": "8f17825cf08a7efea124f2638f3896f6637f8745",     "expires": "2013-09-05T21: 46: 35.729Z" }

    Now you use the token to add it to the authorization header:

    Authorization: Token 8f17825cf08a7efea124f2638f3896f6637f8745

    Up to here it is only to be able to obtain the necessary credentials to be able to interact with AWX

    Now to create a JOB you must use the endpoint / api / v1 / jobs / and send the following by POST, remember the Authorization header:

    name: (string, required)
    
    description: (string, default=””)
    
    job_type: (multiple choice, required)
    run: Run (default)
    check: Check
    scan: Scan
    inventory: (field, default=None)
    
    project: (field, default=None)
    
    playbook: (string, default=””)
    
    credential: (field, default=None)
    
    cloud_credential: (field, default=None)
    
    forks: (integer, default=0)
    
    limit: (string, default=””)
    
    verbosity: (multiple choice)
    0: 0 (Normal) (default)
    1: 1 (Verbose)
    2: 2 (More Verbose)
    3: 3 (Debug)
    4: 4 (Connection Debug)
    5: 5 (WinRM Debug)
    extra_vars: (string, default=””)
    
    job_tags: (string, default=””)
    
    force_handlers: (boolean, default=False)
    
    skip_tags: (string, default=””)
    
    start_at_task: (string, default=””)
    
    job_template: (field, default=None)
    

    Click Authentication Click Jobs

    Greetings.

        
    answered by 27.11.2018 в 15:34