From 5b6956a33ceea9be2e363bb6adf1c4a398ded7e4 Mon Sep 17 00:00:00 2001 From: "Rico Sta. Cruz" Date: Wed, 11 Oct 2017 00:03:36 +0800 Subject: [PATCH] Update heroku and ansible docs to new layout --- ansible-examples.md | 10 +-- ansible-guide.md | 82 ++++++++++++------ ansible-roles.md | 4 +- heroku.md | 205 ++++++++++++++++++++++++++++++-------------- 4 files changed, 203 insertions(+), 98 deletions(-) diff --git a/ansible-examples.md b/ansible-examples.md index 962c87a2b..90b454731 100644 --- a/ansible-examples.md +++ b/ansible-examples.md @@ -1,13 +1,11 @@ --- title: Ansible examples category: Ansible +layout: 2017/sheet --- ### Examples - * [Ruby]( https://github.com/chelsea/ansible-example-ruby/blob/master/roles/webserver/tasks/main.yml ) - - * [Postgres]( https://github.com/chelsea/ansible-example-ruby/blob/master/roles/db/tasks/main.yml ) - - https://github.com/tingtun/ansible-playbook-gitlab - + * [Ruby installation](https://github.com/chelsea/ansible-example-ruby/blob/master/roles/webserver/tasks/main.yml) _(github.com)_ + * [Postgres installation](https://github.com/chelsea/ansible-example-ruby/blob/master/roles/db/tasks/main.yml) _(github.com)_ + * [GitLab installation](https://github.com/tingtun/ansible-playbook-gitlab) _(github.com)_ diff --git a/ansible-guide.md b/ansible-guide.md index 76687781d..7f288a448 100644 --- a/ansible-guide.md +++ b/ansible-guide.md @@ -1,29 +1,40 @@ --- -title: Getting started +title: "Ansible quickstart" category: Ansible +layout: 2017/sheet +description: | + A quick guide to getting started with your first Ansible playbook. --- ### Install Ansible -```sh +```bash $ brew install ansible # OSX -$ [sudo] pip install ansible # elsewhere +$ [sudo] apt install ansible # elsewhere ``` +Ansible is available as a package in most OS's. + +See: [Installation](http://docs.ansible.com/ansible/latest/intro_installation.html) + ### Start your project -```sh +```bash ~$ mkdir setup ~$ cd setup ``` -### Create an inventory file +Make a folder for your Ansible files. -This is a list of hosts you want to manage, grouped into groups. (Hint: try -using 127.0.0.1 to deploy to your local machine) +See: [Getting started](http://docs.ansible.com/ansible/latest/intro_getting_started.html) + +## Creating your files + +### Inventory file + +#### ~/setup/hosts ```dosini -; ~/setup/hosts [sites] 127.0.0.1 192.168.0.1 @@ -31,11 +42,16 @@ using 127.0.0.1 to deploy to your local machine) 192.168.0.3 ``` -### Create your first Playbook +This is a list of hosts you want to manage, grouped into groups. (Hint: try +using `localhost ansible_connection=local` to deploy to your local machine.) + +See: [Intro to Inventory](http://docs.ansible.com/ansible/latest/playbooks_intro.html) + +### Playbook + +#### ~/setup/playbook.yml ```yaml -# ~/setup/playbook.yml - - hosts: 127.0.0.1 user: root tasks: @@ -52,26 +68,38 @@ using 127.0.0.1 to deploy to your local machine) gem: name=bundler state=latest ``` -### Run it +See: [Intro to Playbooks](http://docs.ansible.com/ansible/latest/intro_inventory.html) - ~/setup$ ls - hosts - playbook.yml +## Running - ~/setup$ ansible-playbook -i hosts playbook.yml - PLAY [all] ******************************************************************** +### Running ansible-playbook - GATHERING FACTS *************************************************************** - ok: [127.0.0.1] +``` +~/setup$ ls +hosts +playbook.yml +``` - TASK: [install nginx] ********************************************************* - ok: [127.0.0.1] +#### Running the playbook - TASK: start nginx every bootup] *********************************************** - ok: [127.0.0.1] - ... +``` +~/setup$ ansible-playbook -i hosts playbook.yml +PLAY [all] ******************************************************************** -### Read more +GATHERING FACTS *************************************************************** +ok: [127.0.0.1] - * http://lowendbox.com/blog/getting-started-with-ansible/ - * http://www.ansibleworks.com/docs/modules.html +TASK: [install nginx] ********************************************************* +ok: [127.0.0.1] + +TASK: start nginx every bootup] *********************************************** +ok: [127.0.0.1] +... +``` + +## Read more + +* [Getting started with Ansible](http://lowendbox.com/blog/getting-started-with-ansible/) _(lowendbox.com)_ +* [Getting started](http://docs.ansible.com/ansible/latest/intro_getting_started.html) _(docs.ansible.com)_ +* [Intro to Inventory](http://docs.ansible.com/ansible/latest/intro_inventory.html) _(docs.ansible.com)_ +* [Intro to Playbooks](http://docs.ansible.com/ansible/latest/playbooks_intro.html) _(docs.ansible.com)_ diff --git a/ansible-roles.md b/ansible-roles.md index 25ebdca83..cb1922624 100644 --- a/ansible-roles.md +++ b/ansible-roles.md @@ -1,6 +1,7 @@ --- title: Ansible roles category: Ansible +layout: 2017/sheet --- ### Structure @@ -13,7 +14,8 @@ category: Ansible templates/ # 'template' will refer to this meta/ # Role dependencies here vars/ - defaults/main.yml + defaults/ + main.yml ### References diff --git a/heroku.md b/heroku.md index a82035b3b..ee7a6f31a 100644 --- a/heroku.md +++ b/heroku.md @@ -1,118 +1,195 @@ --- title: Heroku category: Devops +layout: 2017/sheet +updated: 2017-10-11 +description: | + A one-page reference to common Heroku-CLI commands. +intro: | + [Heroku](http://heroku.com/) is a web hosting platform supporting many languages, and this guide is a reference to Heroku's [command-line interface](http://heroku.com/). --- ### `create` - Create an app - heroku create sushi +```bash +heroku create sushi +``` + +```bash +git push heroku master +``` ### `access` - Collaboration - # Manage collaborators - heroku access # List - heroku access:add me@xy.com - heroku access:remove me@xy.com +#### Manage collaborators - # Transfer to another owner - heroku apps:transfer new@owner.com +```bash +heroku access # List +heroku access:add me@xy.com +heroku access:remove me@xy.com +``` + +#### Transfer to another owner + +```bash +heroku apps:transfer new@owner.com +``` ### `logs` - Show logs - heroku logs - heroku logs -t # --tail (stream) - heroku logs -s app # --source (only on app logs) +```bash +heroku logs +heroku logs -t # --tail (stream) +heroku logs -s app # --source (only on app logs) +``` ### `releases` - heroku releases - heroku releases:info v25 - heroku rollback +```bash +heroku releases +heroku releases:info v25 +heroku rollback +``` -### `pg` - Postgresql +### `pg` - PostgreSQL - # Start a database - heroku addons:add heroku-postgresql - heroku pg:promote HEROKU_POSTGRESQL_PURPLE_URL +#### Start a database - # Enable backups - heroku addons:add pgbackups:auto-month +```bash +heroku addons:add heroku-postgresql +``` -### `ps` - Managing processes +#### Enable backups - heroku ps # list - heroku ps:scale web=1 # spawn more dynos +```bash +heroku addons:add pgbackups:auto-month +``` -### `restart` - - heroku restart - -### `run` - Running - - heroku run bash - heroku run console # Rails console - heroku run rake assets:precompile +See: [Heroku PostgreSQL](https://devcenter.heroku.com/articles/heroku-postgresql) _(devcenter.heroku.com)_ ### `config` - Environment var configuration - heroku config # List - heroku config -s # List in shell format +#### Listing - heroku config:get KEY +```bash +heroku config # List +heroku config -s # List in shell format +``` - heroku config:set KEY=val - heroku config:set KEY1=val KEY2=val ... +#### Getting - heroku config:unset KEY1 +```bash +heroku config:get KEY +``` + +#### Setting + +```bash +heroku config:set KEY=val +heroku config:set KEY1=val KEY2=val ... +``` + +```bash +heroku config:unset KEY1 +``` ### `apps` - Applications - heroku apps # list - heroku apps:create [NAME] - heroku apps:destroy --app APP - heroku apps:info - heroku apps:open # open in browser - heroku apps:rename NEWNAME +```bash +heroku apps # list +heroku apps:create [NAME] +heroku apps:destroy --app APP +heroku apps:info +heroku apps:open # open in browser +heroku apps:rename NEWNAME +``` ### `maintenance` - heroku maintenance:on - heroku maintenance:off +```bash +heroku maintenance:on +``` + +```bash +heroku maintenance:off +``` + +## Processes + + +### `ps` - Managing processes + +```bash +heroku ps # list +heroku ps:scale web=1 # spawn more dynos +``` + +### `restart` + +```bash +heroku restart +``` + +### `run` - Running tasks + +```bash +heroku run bash +heroku run console # Rails console +heroku run rake assets:precompile +``` + +## Domains ### `domains` - Custom domains - # Add both! - heroku domains:add example.com - heroku domains:add www.example.com +#### Add both! - # Removing: - heroku domains:clear - heroku domains:remove example.com +```bash +heroku domains:add example.com +heroku domains:add www.example.com +``` + +#### Removing + +```bash +heroku domains:clear +heroku domains:remove example.com +``` + +See: [Custom domains](https://devcenter.heroku.com/articles/custom-domains) _(devcenter.heroku.com)_ ### Wildcard domains - heroku addons:add wildcard_domains +```bash +heroku addons:add wildcard_domains +``` - *.yourdomain.com => heroku.com +```bash +*.yourdomain.com => heroku.com +``` + +## Other tricks ### htpasswd (for PHP apps) Create an `.htaccess` file in the webroot: - AuthUserFile /app/www/.htpasswd - AuthType Basic - AuthName "Restricted Access" - Require valid-user +```bash +AuthUserFile /app/www/.htpasswd +AuthType Basic +AuthName "Restricted Access" +Require valid-user +``` Create a `.htpasswd` file: - $ htpasswd -c .htpasswd [username] +```bash +$ htpasswd -c .htpasswd [username] +``` -See https://gist.github.com/3316425 +See: [gist.github.com](https://gist.github.com/3316425) -### References: +## References - * https://addons.heroku.com/ - * https://devcenter.heroku.com/ - * https://devcenter.heroku.com/articles/custom-domains - * https://devcenter.heroku.com/articles/heroku-postgresql + * + *