Ansible [DRAFT]
Created at 2017-04-21T16:32:41+09:00

TODO

  • follow concepts and implementation

    • local vs remote (execution environment)
    • module, plugin architecture
    • inventory
    • role, playbook
    • idempotency
    • configuration
    • ansible_xxx
    • connection variable
  • development and testing (ansible itself)

Development

$ git submodule init
$ git submodule update
$ . ./hacking/env-setup
$ ./hacking/test-module -m lib/ansible/modules/core/commands/command.py -a "echo hi"
* including generated source, if any, saving to: /home/hiogawa/.ansible_module_generated
* ansiballz module detected; extracted module source to: /home/hiogawa/debug_dir
***********************************
RAW OUTPUT

{"changed": true, "end": "2017-05-09 12:02:03.230056", "stdout": "hi", "cmd": ["echo", "hi"], "rc": 0, "start": "2017-05-09 12:02:03.227978", "stderr": "", "delta": "0:00:00.002078", "invocation": {"module_args": {"warn": true, "executable": null, "chdir": null, "_raw_params": "echo hi", "removes": null, "creates": null, "_uses_shell": false}}, "warnings": []}


***********************************
PARSED OUTPUT
{
    "changed": true,
    "cmd": [
        "echo",
        "hi"
    ],
    "delta": "0:00:00.002078",
    "end": "2017-05-09 12:02:03.230056",
    "invocation": {
        "module_args": {
            "_raw_params": "echo hi",
            "_uses_shell": false,
            "chdir": null,
            "creates": null,
            "executable": null,
            "removes": null,
            "warn": true
        }
    },
    "rc": 0,
    "start": "2017-05-09 12:02:03.227978",
    "stderr": "",
    "stdout": "hi",
    "warnings": []
}

# other way of giving arguments to module
$ ./hacking/test-module -m lib/ansible/modules/core/commands/command.py -a '{ "_raw_params": "pwd", "chdir": "/home/hiogawa" }'

modules/core/commands/command.py

- ansible.module_utils.basic.AnsibleModule.run_command =>
  -

Main path

ansible-playbook execution

I guess something like this?

  • load inventory
  • load playbook
  • load variable
  • module construction ?
    • test-module's boilerplate_module is simpler version of it ? essentially module_common.modify_module ?
    • then, is there something like compile time error ?
    • for ansiballz, we need to transfer dependening utility python module too ?
  • ssh
  • transfer constructed module
  • execute module
(ansible-playbook)
- ...

References