项目作者: xlab-steampunk

项目描述 :
Example Ansible plugins
高级语言: Python
项目地址: git://github.com/xlab-steampunk/ansible-pms-plugins.git
创建时间: 2019-06-13T07:31:46Z
项目社区:https://github.com/xlab-steampunk/ansible-pms-plugins

开源协议:Apache License 2.0

下载


Ping my service Ansible plugins

This repository contains source code for various Ansible plugins that
demonstrate various ways of interacting with web APIs using Ansible. Also
included is the mock service that we can use to test the modules.

Quickstart

First, make sure you have Ansible 2.9.0 or newer installed. Next, start the
mock server:

  1. $ python3 server.py

In another terminal, move to the module or action folder and run:

  1. $ ansible-playbook play.yaml

To test the connection plugin, move to the connection folder and run:

  1. $ ansible-playbook -i inventory.yaml play.yaml

Mock server

The server.py file contains a mock web service that the plugins can be
tested against. We can start the server by running:

  1. $ python3 server.py

To login into the service, we must send a POST request to the /tokens
enspoint. The returned x-auth-token header can then be used to authenticate
all subsequent requests. When we are done, we should terminate the session by
sending a DELETE request to the /tokens/<token> endpoint.

  1. $ curl -v -X POST -H "content-type: application/json" \
  2. -d '{"username": "user", "password": "pass"}' \
  3. localhost:8000/tokens \
  4. 2>&1 | grep x-auth-token
  5. $ curl -H "x-auth-token: 123" localhost:8000/test/me
  6. $ curl -X DELETE -H "x-auth-token: 123" localhost:8000/tokens/123