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
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)_

View File

@ -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,12 +68,21 @@ 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)
## Running
### Running ansible-playbook
```
~/setup$ ls
hosts
playbook.yml
```
#### Running the playbook
```
~/setup$ ansible-playbook -i hosts playbook.yml
PLAY [all] ********************************************************************
@ -70,8 +95,11 @@ using 127.0.0.1 to deploy to your local machine)
TASK: start nginx every bootup] ***********************************************
ok: [127.0.0.1]
...
```
### Read more
## Read more
* http://lowendbox.com/blog/getting-started-with-ansible/
* http://www.ansibleworks.com/docs/modules.html
* [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)_

View File

@ -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

133
heroku.md
View File

@ -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
```bash
heroku create sushi
```
```bash
git push heroku master
```
### `access` - Collaboration
# Manage collaborators
#### Manage collaborators
```bash
heroku access # List
heroku access:add me@xy.com
heroku access:remove me@xy.com
```
# Transfer to another owner
#### Transfer to another owner
```bash
heroku apps:transfer new@owner.com
```
### `logs` - Show logs
```bash
heroku logs
heroku logs -t # --tail (stream)
heroku logs -s app # --source (only on app logs)
```
### `releases`
```bash
heroku releases
heroku releases:info v25
heroku rollback
```
### `pg` - Postgresql
### `pg` - PostgreSQL
# Start a database
#### Start a database
```bash
heroku addons:add heroku-postgresql
heroku pg:promote HEROKU_POSTGRESQL_PURPLE_URL
```
# Enable backups
#### Enable backups
```bash
heroku addons:add pgbackups:auto-month
```
### `ps` - Managing processes
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
See: [Heroku PostgreSQL](https://devcenter.heroku.com/articles/heroku-postgresql) _(devcenter.heroku.com)_
### `config` - Environment var configuration
#### Listing
```bash
heroku config # List
heroku config -s # List in shell format
```
#### Getting
```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
```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`
```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!
#### Add both!
```bash
heroku domains:add example.com
heroku domains:add www.example.com
```
# Removing:
#### 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
```bash
heroku addons:add wildcard_domains
```
```bash
*.yourdomain.com => heroku.com
```
## Other tricks
### htpasswd (for PHP apps)
Create an `.htaccess` file in the webroot:
```bash
AuthUserFile /app/www/.htpasswd
AuthType Basic
AuthName "Restricted Access"
Require valid-user
```
Create a `.htpasswd` file:
```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
* <https://addons.heroku.com/>
* <https://devcenter.heroku.com/>