Repository: ansible/ansible-modules-core

Issue:
docker_service module does not work 
##### ISSUE TYPE
- Bug Report
##### COMPONENT NAME

docker_service
##### ANSIBLE VERSION

```
ansible 2.2.0 (devel 9ad5a32208) last updated 2016/05/17 15:58:35 (GMT +000)
  lib/ansible/modules/core: (detached HEAD 127d518011) last updated 2016/05/17 13:42:30 (GMT +000)
  lib/ansible/modules/extras: (detached HEAD f953d5dc0c) last updated 2016/05/17 13:42:40 (GMT +000)
  config file = 
  configured module search path = Default w/o overrides
```
##### CONFIGURATION

None
##### OS / ENVIRONMENT

Fedora 23
##### SUMMARY

docker_service does not work the way it is documented, and throws a traceback as posted under
##### STEPS TO REPRODUCE

The [docker-compose.yaml](https://github.com/rafabene/devops-demo/blob/master/compose/docker-compose.yml) file I am using is -

```
version: "2"
networks:
  mynet:
services:
  db:
    container_name: "db"
    image: postgres
    networks:
      - mynet
    ports:
       - "5432:5432"
    environment:
      - POSTGRES_USER=ticketmonster
      - POSTGRES_PASSWORD=ticketmonster-docker
  modcluster:
    container_name: "modcluster"
    networks:
      - mynet
    image: karm/mod_cluster-master-dockerhub
    environment:
      - MODCLUSTER_NET=192. 172. 10. 179. 213.
      - MODCLUSTER_PORT=80
    ports:
       - "80:80"
  wildfly:
    image: rafabene/wildfly-ticketmonster-ha
    #build: ../Dockerfiles/ticketmonster-ha/
    networks:
      - mynet
```

The ansible playbook I created -

```
- name: deploy docker compose artifacts
  hosts: localhost
  connection: local
  tasks:
    - name: compose_up
      docker_service:
        project_src: /root/ticket_monster/
        project_name: Ticket Monster
        state: present

    - name: scale_3
      docker_service:
        project_src: /root/ticket_monster/
        state: present
        scale: {'wildfly': 3}

    - name: scale_2
      docker_service:
        project_src: /root/ticket_monster/
        state: present
        scale: {'wildfly': 2}

    - name: compose_down
      docker_service:
        project_src: /root/ticket_monster/
        state: absent
```

To reproduce, run -
`ansible-playbook compose_playbook.yaml`
##### EXPECTED RESULTS

``` bash
# ansible-playbook compose_playbook.yaml 
 [WARNING]: Host file not found: /etc/ansible/hosts

 [WARNING]: provided hosts list is empty, only localhost is available


PLAY [deploy docker compose artifacts] *****************************************

TASK [setup] *******************************************************************
ok: [localhost]

TASK [compose_up] **************************************************************
changed: [localhost]

TASK [scale_3] *****************************************************************
changed: [localhost]

TASK [scale_2] *****************************************************************
changed: [localhost]

TASK [compose_down] ************************************************************
changed: [localhost]

PLAY RECAP *********************************************************************
localhost                  : ok=5    changed=4    unreachable=0    failed=0   
```
##### ACTUAL RESULTS

``` bash
# ansible-playbook --step -vvv compose_playbook.yaml                                                                  
No config file found; using defaults
 [WARNING]: Host file not found: /etc/ansible/hosts

 [WARNING]: provided hosts list is empty, only localhost is available


PLAYBOOK: compose_playbook.yaml ************************************************
1 plays in compose_playbook.yaml

PLAY [deploy docker compose artifacts] *****************************************
Perform task: TASK: setup (N)o/(y)es/(c)ontinue: y

Perform task: TASK: setup (N)o/(y)es/(c)ontinue: *******************************

TASK [setup] *******************************************************************
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: root
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1463502948.45-35859527533704 `" && echo ansible-tmp-1463502948.45-35859527533704="` echo $HOME/.ansible/tmp/ansible-tmp-1463502948.45-35859527533704 `" )'
<127.0.0.1> PUT /tmp/tmp549TTU TO /root/.ansible/tmp/ansible-tmp-1463502948.45-35859527533704/setup.py
<127.0.0.1> EXEC /bin/sh -c 'chmod -R u+x /root/.ansible/tmp/ansible-tmp-1463502948.45-35859527533704/'
<127.0.0.1> EXEC /bin/sh -c 'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /bin/python /root/.ansible/tmp/ansible-tmp-1463502948.45-35859527533704/setup.py; rm -rf "/root/.ansible/tmp/ansible-tmp-1463502948.45-35859527533704/" > /dev/null 2>&1'
ok: [localhost]
Perform task: TASK: compose_up (N)o/(y)es/(c)ontinue: y

Perform task: TASK: compose_up (N)o/(y)es/(c)ontinue: **************************

TASK [compose_up] **************************************************************
task path: /root/compose_env/compose_playbook.yaml:5
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: root
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1463502951.99-46439211651353 `" && echo ansible-tmp-1463502951.99-46439211651353="` echo $HOME/.ansible/tmp/ansible-tmp-1463502951.99-46439211651353 `" )'
<127.0.0.1> PUT /tmp/tmpbxDxDC TO /root/.ansible/tmp/ansible-tmp-1463502951.99-46439211651353/docker_service.py
<127.0.0.1> EXEC /bin/sh -c 'chmod -R u+x /root/.ansible/tmp/ansible-tmp-1463502951.99-46439211651353/'
<127.0.0.1> EXEC /bin/sh -c 'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /bin/python /root/.ansible/tmp/ansible-tmp-1463502951.99-46439211651353/docker_service.py; rm -rf "/root/.ansible/tmp/ansible-tmp-1463502951.99-46439211651353/" > /dev/null 2>&1'
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_iVSEP_/ansible_module_docker_service.py", line 760, in <module>
    main()
  File "/tmp/ansible_iVSEP_/ansible_module_docker_service.py", line 755, in main
    result = ContainerManager(client).exec_module()
  File "/tmp/ansible_iVSEP_/ansible_module_docker_service.py", line 437, in __init__
    super(ContainerManager, self).__init__(module=client.module)
TypeError: __init__() got an unexpected keyword argument 'module'

fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "invocation": {"module_name": "docker_service"}, "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_iVSEP_/ansible_module_docker_service.py\", line 760, in <module>\n    main()\n  File \"/tmp/ansible_iVSEP_/ansible_module_docker_service.py\", line 755, in main\n    result = ContainerManager(client).exec_module()\n  File \"/tmp/ansible_iVSEP_/ansible_module_docker_service.py\", line 437, in __init__\n    super(ContainerManager, self).__init__(module=client.module)\nTypeError: __init__() got an unexpected keyword argument 'module'\n", "module_stdout": "", "msg": "MODULE FAILURE", "parsed": false}

NO MORE HOSTS LEFT *************************************************************
        to retry, use: --limit @compose_playbook.retry

PLAY RECAP *********************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1   

```



Discussion:

Resolving patch:
diff --git a/cloud/docker/docker_service.py b/cloud/docker/docker_service.py
--- a/cloud/docker/docker_service.py
+++ b/cloud/docker/docker_service.py
@@ -434,7 +434,7 @@ class ContainerManager(DockerBaseClass):
 
     def __init__(self, client):
 
-        super(ContainerManager, self).__init__(module=client.module)
+        super(ContainerManager, self).__init__()
 
         self.client = client
         self.project_src = None


Test patch: