Drone

Ansible Plugin - Docker Connection to Service Container

I am trying to write a pipeline to lint and execute my ansible code for testing. I am using a service to do this. Would something like this actually be possible?

Below is my drone.yml file.


---
kind: pipeline
type: docker
name: default

services:
- name: photon
  image: photon:latest

steps:
- name: Lint Ansible Playbook
  image: plugins/ansible:2
  settings:
    playbook: playbook.yml
    syntax_check: true
    inventory: ./inventory
    verbose: 2
- name: Run Ansible Playbook
  image: plugins/ansible:2
  settings:
    playbook: playbook.yml
    connection: docker
    syntax_check: false
    inventory: ./inventory
    verbose: 3
    list_hosts: true

The error that I get is:

$ ansible --version
ansible 2.8.4
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.7.3 (default, May  3 2019, 11:24:39) [GCC 8.3.0]
$ ansible-playbook --inventory ./inventory --connection docker playbook.yml

PLAY [Test Playbook] ***********************************************************

TASK [Gathering Facts] *********************************************************
fatal: [photon]: FAILED! => {"msg": "docker command not found in PATH"}

PLAY RECAP *********************************************************************
photon                     : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   

exit status 2

I am not familiar with ansible, but it looks like the docker binary is missing from the photon container. When photon tries to execute a docker command the docker binary is not found:

fatal: [photon]: FAILED! => {"msg": "docker command not found in PATH"}

In addition, you need to make sure the docker binary can connect to a running docker daemon. See the examples section of the pipeline documentation for a few different options for connecting to docker daemons.

Yea I believe the issue is that ansible is looking for docker in the path of the plugins/ansible container image. Since it is not there it is unable to connect to the Photon container instance that I have defined in the service. Docker seems like the best option since sshd is not installed on most docker images.