{"id":13753260,"url":"https://github.com/rgee0/openfaas-on-digitalocean","last_synced_at":"2025-05-07T08:23:24.886Z","repository":{"id":115402784,"uuid":"131405142","full_name":"rgee0/openfaas-on-digitalocean","owner":"rgee0","description":"Ansible playbook to create a Digital Ocean droplet and deploy OpenFaaS onto it.","archived":false,"fork":false,"pushed_at":"2018-12-28T17:27:11.000Z","size":32,"stargazers_count":60,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-31T08:07:03.989Z","etag":null,"topics":["ansible","digital-ocean","droplet","k8s","kubernetes","kubernetes-setup","openfaas","playbook","serverless"],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rgee0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-04-28T11:51:19.000Z","updated_at":"2025-01-21T04:03:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"2591a6c8-1d43-482d-bf17-b5d3c51b763f","html_url":"https://github.com/rgee0/openfaas-on-digitalocean","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rgee0%2Fopenfaas-on-digitalocean","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rgee0%2Fopenfaas-on-digitalocean/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rgee0%2Fopenfaas-on-digitalocean/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rgee0%2Fopenfaas-on-digitalocean/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rgee0","download_url":"https://codeload.github.com/rgee0/openfaas-on-digitalocean/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252840103,"owners_count":21812240,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","digital-ocean","droplet","k8s","kubernetes","kubernetes-setup","openfaas","playbook","serverless"],"created_at":"2024-08-03T09:01:19.255Z","updated_at":"2025-05-07T08:23:24.865Z","avatar_url":"https://github.com/rgee0.png","language":null,"funding_links":[],"categories":["playbook"],"sub_categories":[],"readme":"## OpenFaaS-on-DigitalOcean\n\nAnsible Playbook to get you up and running with OpenFaas on [DigitalOcean](https://m.do.co/c/2962aa9e56a1).  This is intended for evaluation / testing where quick and repeatable access to a clean instance is desired.\n\nPlease be aware this playbook is not idempotent, specifically in droplet creation; if you run it _n_ times you will get _n_ droplets.\n\nBoth swarm and kubernetes deployments are possible by passing `-e \"orchestrator=swarm\"` or `-e \"orchestrator=k8s\"`. \n\n### Pre-requisites\n\nThese vary depending on the mechanism by which Ansible is being invoked.  If Ansible is being installed onto a control machine then all three apply.  Alternatively a Docker image has been made available at `rgee0/ansible-playbook:2.6.0` which includes the first two pre-reqs.\n\n* [Install Ansible](http://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html) (Skip if using Docker image)\n* [PIP](https://pip.pypa.io/en/stable/installing/) and [DOPY](https://pypi.org/project/dopy) (Skip if using Docker image)\n* [DigitalOcean](https://m.do.co/c/2962aa9e56a1) account\n\n### Configure Variables\n\nConfigure the [create_droplet role variables](create_droplet/vars/main.yml) according to your needs.\n\n```yml\n\n  token: \u003cyour DO API token\u003e\n  sshid: \u003cyour ssh key ids\u003e\n  size_slug: \u003cyour required vm size\u003e\n  region: \u003cyour desired region\u003e\n  image: ubuntu-17-10-x64\n\n```\n\n* token\n\nClick API in the DigitalOcean Dashboard, then under Tokens/Keys click “Generate New Token”.  Select Read \u0026 Write scopes.\n\n* sshid\n\nThe ssh key IDs can be found by running:\n```sh\n$ export DOTOKEN=\u003cAPI token\u003e\n$ curl -X GET -H 'Content-Type: application/json' -H 'Authorization: Bearer '$DOTOKEN \"https://api.digitalocean.com/v2/account/keys\" 2\u003e/dev/null | python -m json.tool\n```\nLook at the “ssh_keys” section and pick one of the SSH keys you want to use to log into the new droplet we will create. Use the “name” field to identify the key and then copy the “id” field\n\n* size_slug\n\nIts recommended that `s-2vcpu-4gb` is used as a minimum.  Further options can be found on [DigitalOcean](https://developers.digitalocean.com/documentation/changelog/api-v2/new-size-slugs-for-droplet-plan-changes/)\n\nor through the API:\n```sh\n$ curl -X GET -H 'Content-Type: application/json' -H 'Authorization: Bearer '$DOTOKEN \"https://api.digitalocean.com/v2/sizes\" 2\u003e/dev/null | python -m json.tool\n```\n\n* region\n\n```\n$ curl -X GET -H 'Content-Type: application/json' -H 'Authorization: Bearer '$DOTOKEN \"https://api.digitalocean.com/v2/regions\" 2\u003e/dev/null | python -m json.tool\n```\n\n### Run the playbook\n\n* Using Swarm (Ansible via Docker)\n\nEnsure the path to, and key names, are adjusted according to your set-up.\n\n```sh\n$ docker run --rm -it -v $(pwd):/ansible/playbooks \\\n                      -v ~/.ssh/id_rsa:/root/.ssh/id_rsa \\\n                      -v ~/.ssh/id_rsa.pub:/root/.ssh/id_rsa.pub \\\n                      rgee0/ansible-playbook:2.6.0 site.yml -e \"orchestrator=swarm\"\n```\n\n* Using Kubernetes (Ansible via Docker)\n\nEnsure the path to, and key names, are adjusted according to your set-up.\n\n```sh\n$ docker run --rm -it -v $(pwd):/ansible/playbooks \\\n                      -v ~/.ssh/id_rsa:/root/.ssh/id_rsa \\\n                      -v ~/.ssh/id_rsa.pub:/root/.ssh/id_rsa.pub \\\n                      rgee0/ansible-playbook:2.6.0 site.yml -e \"orchestrator=k8s\"\n```\n\n* Using Swarm (local Ansible installation)\n```sh\n$ ansible-playbook site.yml -e \"orchestrator=swarm\"\n```\n\n* Using Kubernetes (local Ansible installation)\n```sh\n$ ansible-playbook site.yml -e \"orchestrator=k8s\"\n```\n\n### Head over to the UI\n\nCheck the output of the final task to find the location of the OpenFaaS UI.  For example:\n```\nok: [209.97.188.227] =\u003e {\n    \"msg\": [\n        \"OpenFaaS Gateway: http://209.97.188.227:8080\",\n        \"Gateway User: admin \",\n        \"Gateway Password: c2db2b6d59df518392a81eff57c52486f9f2f46e2480d9de150904bbce0560bc\",\n        \"CLI Gateway Login: echo -n c2db2b6d59df518392a81eff57c52486f9f2f46e2480d9de150904bbce0560bc | faas-cli login --username=admin --password-stdin -g http://209.97.188.227:8080\"\n    ]\n}\n\nPLAY RECAP **************************************************************************************************************************\n209.97.188.227             : ok=12   changed=6    unreachable=0    failed=0\nlocalhost                  : ok=6    changed=2    unreachable=0    failed=0\n```\n\nAs this deploys to public cloud basic auth is enabled by default for both orchestrators.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frgee0%2Fopenfaas-on-digitalocean","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frgee0%2Fopenfaas-on-digitalocean","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frgee0%2Fopenfaas-on-digitalocean/lists"}