On Mon, 16 Oct 2017, at 12:44, Dave Cottlehuber wrote:
> hi folks
> 
> I'd like to trigger ansible from a webhook - a github commit in this
> case. How have other people done this?
> 
> A+
> Dave

I'm still interested to hear what others do, but here's a working
solution from today's hacking using haproxy (for TLS termination and
some access control restrictions) and exposing
https://github.com/adnanh/webhook and the following webhook.json file:

```json
[
    {
        "id": "ansible",
        "execute-command": "make daemons",
        "command-working-directory": "/home/deploy/src/ansible",
        "pass-arguments-to-command":
        [
            {
                "source": "payload",
                "name": "head_commit.id"
            },
            {
                "source": "payload",
                "name": "pusher.name"
            },
            {
                "source": "payload",
                "name": "pusher.email"
            }
        ],
        "trigger-rule":
        {
            "and":
            [
                {
                    "match":
                    {
                        "type": "payload-hash-sha1",
                        "secret": "{{ config.webhook.secret }}",
                        "parameter":
                        {
                            "source": "header",
                            "name": "X-Hub-Signature"
                        }
                    }
                }
            ]
        }
    }
]
```

In my case, the "entry point" for all ansible playbooks is handled in a
Makefile. webhook provides either command-line parameter passing, or
environment variables.

A+
Dave

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/1508171514.1089501.1140532720.15ACC084%40webmail.messagingengine.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to