Update heroku and ansible docs to new layout

This commit is contained in:
Rico Sta. Cruz 2017-10-11 00:03:36 +08:00
parent bb95d6ddc0
commit 5b6956a33c
No known key found for this signature in database
GPG Key ID: CAAD38AE2962619A
4 changed files with 203 additions and 98 deletions

View File

@ -1,13 +1,11 @@
--- ---
title: Ansible examples title: Ansible examples
category: Ansible category: Ansible
layout: 2017/sheet
--- ---
### Examples ### Examples
* [Ruby]( https://github.com/chelsea/ansible-example-ruby/blob/master/roles/webserver/tasks/main.yml ) * [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)_
* [Postgres]( https://github.com/chelsea/ansible-example-ruby/blob/master/roles/db/tasks/main.yml ) * [GitLab installation](https://github.com/tingtun/ansible-playbook-gitlab) _(github.com)_
https://github.com/tingtun/ansible-playbook-gitlab

View File

@ -1,29 +1,40 @@
--- ---
title: Getting started title: "Ansible quickstart"
category: Ansible category: Ansible
layout: 2017/sheet
description: |
A quick guide to getting started with your first Ansible playbook.
--- ---
### Install Ansible ### Install Ansible
```sh ```bash
$ brew install ansible # OSX $ 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 ### Start your project
```sh ```bash
~$ mkdir setup ~$ mkdir setup
~$ cd 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 See: [Getting started](http://docs.ansible.com/ansible/latest/intro_getting_started.html)
using 127.0.0.1 to deploy to your local machine)
## Creating your files
### Inventory file
#### ~/setup/hosts
```dosini ```dosini
; ~/setup/hosts
[sites] [sites]
127.0.0.1 127.0.0.1
192.168.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 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 ```yaml
# ~/setup/playbook.yml
- hosts: 127.0.0.1 - hosts: 127.0.0.1
user: root user: root
tasks: tasks:
@ -52,12 +68,21 @@ using 127.0.0.1 to deploy to your local machine)
gem: name=bundler state=latest gem: name=bundler state=latest
``` ```
### Run it See: [Intro to Playbooks](http://docs.ansible.com/ansible/latest/intro_inventory.html)
## Running
### Running ansible-playbook
```
~/setup$ ls ~/setup$ ls
hosts hosts
playbook.yml playbook.yml
```
#### Running the playbook
```
~/setup$ ansible-playbook -i hosts playbook.yml ~/setup$ ansible-playbook -i hosts playbook.yml
PLAY [all] ******************************************************************** PLAY [all] ********************************************************************
@ -70,8 +95,11 @@ using 127.0.0.1 to deploy to your local machine)
TASK: start nginx every bootup] *********************************************** TASK: start nginx every bootup] ***********************************************
ok: [127.0.0.1] ok: [127.0.0.1]
... ...
```
### Read more ## Read more
* http://lowendbox.com/blog/getting-started-with-ansible/ * [Getting started with Ansible](http://lowendbox.com/blog/getting-started-with-ansible/) _(lowendbox.com)_
* http://www.ansibleworks.com/docs/modules.html * [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)_

View File

@ -1,6 +1,7 @@
--- ---
title: Ansible roles title: Ansible roles
category: Ansible category: Ansible
layout: 2017/sheet
--- ---
### Structure ### Structure
@ -13,7 +14,8 @@ category: Ansible
templates/ # 'template' will refer to this templates/ # 'template' will refer to this
meta/ # Role dependencies here meta/ # Role dependencies here
vars/ vars/
defaults/main.yml defaults/
main.yml
### References ### References

133
heroku.md
View File

@ -1,118 +1,195 @@
--- ---
title: Heroku title: Heroku
category: Devops 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 ### `create` - Create an app
```bash
heroku create sushi heroku create sushi
```
```bash
git push heroku master
```
### `access` - Collaboration ### `access` - Collaboration
# Manage collaborators #### Manage collaborators
```bash
heroku access # List heroku access # List
heroku access:add me@xy.com heroku access:add me@xy.com
heroku access:remove me@xy.com heroku access:remove me@xy.com
```
# Transfer to another owner #### Transfer to another owner
```bash
heroku apps:transfer new@owner.com heroku apps:transfer new@owner.com
```
### `logs` - Show logs ### `logs` - Show logs
```bash
heroku logs heroku logs
heroku logs -t # --tail (stream) heroku logs -t # --tail (stream)
heroku logs -s app # --source (only on app logs) heroku logs -s app # --source (only on app logs)
```
### `releases` ### `releases`
```bash
heroku releases heroku releases
heroku releases:info v25 heroku releases:info v25
heroku rollback heroku rollback
```
### `pg` - Postgresql ### `pg` - PostgreSQL
# Start a database #### Start a database
```bash
heroku addons:add heroku-postgresql heroku addons:add heroku-postgresql
heroku pg:promote HEROKU_POSTGRESQL_PURPLE_URL ```
# Enable backups #### Enable backups
```bash
heroku addons:add pgbackups:auto-month heroku addons:add pgbackups:auto-month
```
### `ps` - Managing processes See: [Heroku PostgreSQL](https://devcenter.heroku.com/articles/heroku-postgresql) _(devcenter.heroku.com)_
heroku ps # list
heroku ps:scale web=1 # spawn more dynos
### `restart`
heroku restart
### `run` - Running
heroku run bash
heroku run console # Rails console
heroku run rake assets:precompile
### `config` - Environment var configuration ### `config` - Environment var configuration
#### Listing
```bash
heroku config # List heroku config # List
heroku config -s # List in shell format heroku config -s # List in shell format
```
#### Getting
```bash
heroku config:get KEY heroku config:get KEY
```
#### Setting
```bash
heroku config:set KEY=val heroku config:set KEY=val
heroku config:set KEY1=val KEY2=val ... heroku config:set KEY1=val KEY2=val ...
```
```bash
heroku config:unset KEY1 heroku config:unset KEY1
```
### `apps` - Applications ### `apps` - Applications
```bash
heroku apps # list heroku apps # list
heroku apps:create [NAME] heroku apps:create [NAME]
heroku apps:destroy --app APP heroku apps:destroy --app APP
heroku apps:info heroku apps:info
heroku apps:open # open in browser heroku apps:open # open in browser
heroku apps:rename NEWNAME heroku apps:rename NEWNAME
```
### `maintenance` ### `maintenance`
```bash
heroku maintenance:on heroku maintenance:on
```
```bash
heroku maintenance:off 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 ### `domains` - Custom domains
# Add both! #### Add both!
```bash
heroku domains:add example.com heroku domains:add example.com
heroku domains:add www.example.com heroku domains:add www.example.com
```
# Removing: #### Removing
```bash
heroku domains:clear heroku domains:clear
heroku domains:remove example.com heroku domains:remove example.com
```
See: [Custom domains](https://devcenter.heroku.com/articles/custom-domains) _(devcenter.heroku.com)_
### Wildcard domains ### Wildcard domains
```bash
heroku addons:add wildcard_domains heroku addons:add wildcard_domains
```
```bash
*.yourdomain.com => heroku.com *.yourdomain.com => heroku.com
```
## Other tricks
### htpasswd (for PHP apps) ### htpasswd (for PHP apps)
Create an `.htaccess` file in the webroot: Create an `.htaccess` file in the webroot:
```bash
AuthUserFile /app/www/.htpasswd AuthUserFile /app/www/.htpasswd
AuthType Basic AuthType Basic
AuthName "Restricted Access" AuthName "Restricted Access"
Require valid-user Require valid-user
```
Create a `.htpasswd` file: Create a `.htpasswd` file:
```bash
$ htpasswd -c .htpasswd [username] $ 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://addons.heroku.com/>
* https://devcenter.heroku.com/ * <https://devcenter.heroku.com/>
* https://devcenter.heroku.com/articles/custom-domains
* https://devcenter.heroku.com/articles/heroku-postgresql