Repository: ansible/ansible-modules-core

Issue:
digital_ocean private networking option does not work
##### Issue Type:

Bug Report
##### Ansible Version:

```
ansible --version
ansible 1.9 (devel 41399dedaf) last updated 2014/12/28 10:29:49 (GMT -700)
  lib/ansible/modules/core: (detached HEAD f9574cc318) last updated 2014/12/28 10:30:08 (GMT -700)
  lib/ansible/modules/extras: (detached HEAD 317654dba5) last updated 2014/12/28 10:30:08 (GMT -700)
  v2/ansible/modules/core: (detached HEAD cb69744bce) last updated 2014/11/07 12:35:55 (GMT -700)
  v2/ansible/modules/extras: (detached HEAD 8a4f07eecd) last updated 2014/11/07 12:36:08 (GMT -700)
  configured module search path = /usr/share/ansible
```
##### Environment:

Ubuntu 14.04 64bit on both client and server.

pip install dopy outputs:

```
Downloading/unpacking dopy
  Downloading dopy-0.3.0.tar.gz
  Running setup.py (path:/tmp/pip_build_root/dopy/setup.py) egg_info for package dopy

Requirement already satisfied (use --upgrade to upgrade): requests>=1.0.4 in /usr/lib/python2.7/dist-packages (from dopy)
Installing collected packages: dopy
  Running setup.py install for dopy
```
##### Summary:

Setting `private_networking: yes` does not initiate a private networking NIC on my droplets. The droplets are in the nyc2 region, which is listed as supporting private networking.
##### Steps To Reproduce:

Run this task:

``` yaml
- name: Intiate example.com
    digital_ocean:
      name: example.com
      state: present
      api_key: "{{ digitalocean_api_v1_key }}"
      backups_enabled: yes
      client_id: "{{ digitalocean_api_v1_client_id }}"
      command: droplet
      image_id: "{{ digitalocean_api_v1_ubuntu_64bit_id }}"
      private_networking: yes
      region_id: "{{ digitalocean_api_v1_nyc2_id }}"
      size_id: "{{ digitalocean_api_v1_512MB_id }}"
      ssh_key_ids: "{{ digitalocean_api_v1_ssh_key_ids }}"
      unique_name: yes
      virtio: yes
      wait: yes
      wait_timeout: 300
```

Check DO settings page for private networking, and find none. SSH into droplet, and find no private network NIC.
##### Expected Results:

A private networking NIC enabled on the droplet.
##### Actual Results:

No private networking NIC enabled on the droplet.



Discussion:
I see the same issue.

Hello,

It's also happening to me:

$ ansible --version
ansible 1.8.2
  configured module search path = None

Using dopy (0.2.3).

I have the same issue:

```
ansible --version
ansible 1.8.2
```

verbose command:
`REMOTE_MODULE digital_ocean name=<omitted> private_networking=yes ssh_key_ids=<omitted> command=droplet state=present size_id=66 unique_name=yes`

result:

```
"changed": true,
"droplet": {
    "backups": [],
    "backups_active": false,
    "created_at": "2015-01-07T11:14:54Z",
    "event_id": <omitted>,
    "id": <omitted>,
    "image_id": 6918990,
    "ip_address": "<omitted>",
    "locked": false,
    "name": "<omitted>",
    "private_ip_address": null,
    "region_id": 5,
    "size_id": 66,
    "snapshots": [],
    "status": "active"
},
"invocation": {
    "module_args": "",
    "module_name": "digital_ocean"
},
```

edit:
after some debug:

using directly dopy:
`do.new_droplet(name='newdroplet', size_id=66, image_id=6918990, region_id=5, private_networking=True`

```
{u'backups': [],
 u'backups_active': False,
 u'created_at': u'2015-01-07T12:13:39Z',
 u'id': <omitted>,
 u'image_id': 6918990,
 u'ip_address': None,
 u'locked': False,
 u'name': u'newdroplet',
 u'private_ip_address': None,
 u'region_id': 5,
 u'size_id': 66,
 u'snapshots': [],
 u'status': u'archive'}
```

EDIT2:

after some investigation seems like digital ocean is expecting the values to be in lower case.

I also have this issue. My playbook is pasted in.

---
- hosts: localhost
  connection: local
  tasks:
  - name: create hosts
    digital_ocean: >
      state=present
      wait=no
      command=droplet
      name={{ item }}
      unique_name=yes
      size_id=64
      region_id=8
      ssh_key_ids=632003
      image_id=9801950
      private_networking=yes
    with_items:
    - host0
    - host1
    - host2
    - host3
    - host4
    - host5

Fixed by:

diff --git a/cloud/digital_ocean/digital_ocean.py b/cloud/digital_ocean/digital_ocean.py
index efebf5f..76fd3ea 100644
--- a/cloud/digital_ocean/digital_ocean.py
+++ b/cloud/digital_ocean/digital_ocean.py
@@ -339,7 +339,7 @@ def core(module):
                     region_id=getkeyordie('region_id'),
                     ssh_key_ids=module.params['ssh_key_ids'],
                     virtio=module.params['virtio'],
-                    private_networking=module.params['private_networking'],
-                    private_networking=str(module.params['private_networking']).lower(),
                   backups_enabled=module.params['backups_enabled'],
               )


Resolving patch:
diff --git a/cloud/digital_ocean/digital_ocean.py b/cloud/digital_ocean/digital_ocean.py
--- a/cloud/digital_ocean/digital_ocean.py
+++ b/cloud/digital_ocean/digital_ocean.py
@@ -236,7 +236,8 @@ def setup(cls, client_id, api_key):
 
     @classmethod
     def add(cls, name, size_id, image_id, region_id, ssh_key_ids=None, virtio=True, private_networking=False, backups_enabled=False):
-        json = cls.manager.new_droplet(name, size_id, image_id, region_id, ssh_key_ids, virtio, private_networking, backups_enabled)
+        private_networking_lower = str(private_networking).lower()
+        json = cls.manager.new_droplet(name, size_id, image_id, region_id, ssh_key_ids, virtio, private_networking_lower, backups_enabled)
         droplet = cls(json)
         return droplet
 


Test patch: