DigitalOcean: Error creating tags
OS / Environment
MacOS
Ansible version
2.2.0.0
Version of components from requirements.txt
msrestazure: 0.4.17 setuptools: 38.2.3 ansible: 2.2.0.0 dopy: 0.3.5 boto: 2.48.0 boto3: 1.4.8 azure: 2.0.0rc5 msrest: 0.4.1 apache-libcloud: 2.2.1 six: 1.11.0 pyopenssl: 17.4.0 jinja2: 2.8
Summary of the problem
Digitalocean deployment fails when setting tags
Steps to reproduce the behavior
Run ./algo for digitalocean region #8, all [y/N] options set to yes.
The way of deployment (cloud or local)
local
Expected behavior
Ansible sets the tags for the droplet
Actual behavior
Get an error: fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "Failed as requested from task"}
Full log
What provider would you like to use? 1. DigitalOcean 2. Amazon EC2 3. Microsoft Azure 4. Google Compute Engine 5. Install to existing Ubuntu 16.04 server
Enter the number of your desired provider : 1
Enter your API token. The token must have read and write permissions (https://cloud.digitalocean.com/settings/api/tokens): [pasted values will not be displayed] :
Name the vpn server: [algo.local]:
What region should the server be located in? 1. Amsterdam (Datacenter 2) 2. Amsterdam (Datacenter 3) 3. Frankfurt 4. London 5. New York (Datacenter 1) 6. New York (Datacenter 2) 7. New York (Datacenter 3) 8. San Francisco (Datacenter 1) 9. San Francisco (Datacenter 2) 10. Singapore 11. Toronto 12. Bangalore Enter the number of your desired region: [7]: 8
Do you want macOS/iOS clients to enable "VPN On Demand" when connected to cellular networks? [y/N]: y
Do you want macOS/iOS clients to enable "VPN On Demand" when connected to Wi-Fi? [y/N]: y
List the names of trusted Wi-Fi networks (if any) that macOS/iOS clients exclude from using the VPN (e.g., your home network. Comma-separated value, e.g., HomeNet,OfficeWifi,AlgoWiFi) :
Do you want to install a DNS resolver on this VPN server, to block ads while surfing? [y/N]: y
Do you want each user to have their own account for SSH tunneling? [y/N]: y
Do you want to apply operating system security enhancements on the server? (warning: replaces your sshd_config) [y/N]: y
Do you want the VPN to support Windows 10 or Linux Desktop clients? (enables compatible ciphers and key exchange, less secure) [y/N]: y
Do you want to retain the CA key? (required to add users in the future, but less secure) [y/N]: y
PLAY [Configure the server] ****************************************************
TASK [setup] ******************************************************************* ok: [localhost]
TASK [Generate the SSH private key] ******************************************** ok: [localhost]
TASK [Generate the SSH public key] ********************************************* ok: [localhost]
TASK [Change mode for the SSH private key] ************************************* ok: [localhost]
TASK [Ensure the dynamic inventory exists] ************************************* ok: [localhost]
TASK [cloud-digitalocean : Set the DigitalOcean Access Token fact] ************* ok: [localhost]
TASK [cloud-digitalocean : Delete the existing Algo SSH keys] ****************** FAILED - RETRYING: TASK: cloud-digitalocean : Delete the existing Algo SSH keys (10 retries left). ok: [localhost]
TASK [cloud-digitalocean : Upload the SSH key] ********************************* changed: [localhost]
TASK [cloud-digitalocean : Creating a droplet...] ****************************** ok: [localhost]
TASK [cloud-digitalocean : Add the droplet to an inventory group] ************** changed: [localhost]
TASK [cloud-digitalocean : set_fact] ******************************************* ok: [localhost]
TASK [cloud-digitalocean : Tag the droplet] ************************************ failed: [localhost] (item=staging) => {"failed": true, "item": "staging", "msg": "error tagging resource '73204383': param is missing or the value is empty: resources"} failed: [localhost] (item=dbserver) => {"failed": true, "item": "dbserver", "msg": "error tagging resource '73204383': param is missing or the value is empty: resources"} Debugger invoked (debug) c
TASK [cloud-digitalocean : debug] ********************************************** ok: [localhost] => { "fail_hint": [ "Sorry, but something went wrong!", "Please check the troubleshooting guide.", "https://trailofbits.github.io/algo/troubleshooting.html" ] }
TASK [cloud-digitalocean : fail] *********************************************** fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "Failed as requested from task"} Debugger invoked (debug) c
PLAY RECAP ********************************************************************* localhost : ok=12 changed=2 unreachable=0 failed=1
Am also experience this issue.
I added the droplet's tag by hand. The tag is Environment:Algo and after that, the installation worked
same problem
@thalessr, how/where did you add the tag?
@gtb104, basically follow this tutorial https://www.digitalocean.com/community/tutorials/how-to-tag-digitalocean-droplets and as a the droplet's tag, add Environment:Algo because the installation's script will find the droplet by this tag.
A reminder in the command ansible-playbook deploy.yml -t digitalocean,vpn,cloud -e 'do_access_token=my_secret_token do_server_name=algo.local do_region=ams2' specifies algo.local as your droplet name and the tag must be add on this droplet.
@thalessr, after tagging, it there anything you need to do to "continue the installation", or was that the last step?
If there's a problem with the readme, please submit a PR!
Looks like an issue has been opened against Ansible.
@gtb104 yes, I forgot to mention it.. my bad =(. However, it is needed to rerun the installation commands with the same parameters. Eg: if in your first attempt it was used ansible-playbook deploy.yml -t digitalocean,vpn,cloud -e 'do_access_token=my_secret_token do_server_name=algo.local do_region=ams2' rerun it after adding the tags.
Until the patch has been merged and ansible gets updated, as a quick workaround you can make the little change from the commit in your local installation (see changed code in the link).
Here's a patch file you can use to get going again. Save the following patch to your algo directory in a file called, for example, do_tag.patch. Then run patch -b -p0 < do_tag.patch.
--- ./env/lib/python2.7/site-packages/ansible/modules/core/cloud/digital_ocean/digital_ocean_tag.py.orig 2017-12-02 09:42:56.044524930 -0500
+++ ./env/lib/python2.7/site-packages/ansible/modules/core/cloud/digital_ocean/digital_ocean_tag.py 2017-12-02 09:43:14.245074861 -0500
@@ -242,7 +242,7 @@
module = AnsibleModule(
argument_spec=dict(
name=dict(type='str', required=True),
- resource_id=dict(aliases=['droplet_id'], type='int'),
+ resource_id=dict(aliases=['droplet_id'], type='str'),
resource_type=dict(choices=['droplet'], default='droplet'),
state=dict(choices=['present', 'absent'], default='present'),
api_token=dict(aliases=['API_TOKEN'], no_log=True),
@thalessr Hmm, I added that tag (Environment:Algo ) to my droplet in Digital Ocean, but re-running the deploy script yields the same error as before. @gtb104 Were you able to get it to work this way? Was there anything else you had to do to make it work?
Thanks to @davidemyers, I created his patch file and ran the patch command before running ./algo. The Algo script completed successfully.
Confirmed that worked for me. Thank you!
@davidemyers works like a charm, thanks a lot!
The patch unfortunately does not work for me :(
TASK [cloud-digitalocean : Tag the droplet] ************************************
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "error tagging resource '73812578': The resource you were accessing could not be found."}
Do you guys have any other workaround? Thanks!
Can't reproduce now. Looks like DO accepts both int and str now. Could anyone verify also?
I agree, with the patch I posted above backed out I can create droplets again.
@gunph1ld This has started to fail again without the patch, and resolves with the patch applied.