Show version
------------

$ linchpin --version

Create workspace
----------------

$ mkdir ~/example_ws

Create PinFile
--------------

.. code-block:: yaml

    $ cat ~/example_ws/PinFile
    ---
    os-single-test:
      topology: openstack-single.yml
      layout: openstack-single.yml

Create topology
---------------

.. code-block:: yaml

    $ cat ~/example_ws/topologies/openstack-single.yml
    ---
    topology_name: os-single
    resource_groups:
      - resource_group_name: openstack-single
        resource_group_type: openstack
        resource_definitions:
          - name: example
            type: os_server
            flavor: m1.small
            image: rhel-7.2-server-x86_64-released
            count: 1
            keypair: ci-factory
            networks:
              - atomic-e2e-jenkins-test
            fip_pool: 10.8.172.0/22
        credentials:
          filename: clouds.yaml
          profile: ci-osp

# to get actual success, use --creds-path of ~/.config/openstack/, not ~/.config/linchpin/

Create layout
-------------

.. code-block:: yaml

    $ cat example_ws/layouts/openstack-single.yml
    ---
    inventory_layout:
      vars:
        hostname: __IP__
      hosts:
        example-node:
          count: 1
          host_groups:
            - example

Display credentials
------------------

.. code-block:: yaml

    $ cat ~/.config/linchpin/clouds.yaml
    ---
    clouds:
      default:
        auth:
          auth_url: http://dashboard.redhat.org:5000/v2.0/
          project_name: atomic-jenkins
          username: atomic-jenkins
          password: password
      ci-osp:
        auth:
          auth_url: http://dashboard.redhat.org:5000/v2.0/
          project_name: atomic-jenkins-test
          username: atomic-jenkins-test
          password: password


Create hooks
------------

Add hooks section to Pinfile

.. code-block: yaml

    $ cat ~/example_ws/PinFile
    ---
    os-single-test:
      topology: openstack-single.yml
      layout: openstack-single.yml
      hooks:
        postup:
          - type: ansible
            name: ping
            context: True
            actions:
              - playbook: os_ping.yaml
                extra_vars: {"ansible_ssh_private_key_file": "/home/herlo/Projects/rh/git/atomic-ci-jobs/project/config/keys/ci-factory"}

.. code-block: bash

    $ mkdir -p example_ws/hooks/ansible/ping

    $ cat ~/example_ws/hooks/ansible/ping/os_ping.yaml
    ---
    - hosts: example
      tasks:
        - name: ping
          ping:

    $ tree example_ws/hooks/
    example_ws/hooks/
    └── ansible
        └── ping
            └── os_ping.yaml

Run provision with ping
-----------------------

.. code-block: bash

    $ export ANSIBLE_HOST_KEY_CHECKING=False
    $ time linchpin --creds-path ~/.config/openstack/ up os-single-test
