Skip to content

Commit 138ee7a

Browse files
committed
add notes from new prod + staging setup to readme
1 parent d53bc58 commit 138ee7a

File tree

1 file changed

+69
-58
lines changed

1 file changed

+69
-58
lines changed

README.md

+69-58
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,104 @@
1-
### Lobste.rs Ansible Playbook
1+
# Lobste.rs Ansible Playbook
22

33
Ansible playbook for lobste.rs.
4-
54
Lobsters is a technology-focused link aggregation site.
65

6+
See the notes below if you're using this to set up your own site.
7+
78
To run:
89

910
$ ansible-playbook -K prod.yml
1011

11-
When working on test:
12-
13-
$ ansible-playbook --inventory=inventories/test.ini -K prod.yml
14-
12+
When working on staging:
1513

16-
#### Playbooks
14+
$ ansible-playbook --inventory=inventories/staging.ini -K staging.yml
1715

18-
backup - TODO: backup site.
19-
prod - deploy to production.
20-
restore - TODO: restore from backup.
2116

22-
23-
#### Inventory
17+
## Inventory
2418

2519
The following host groups are available:
2620

27-
backup - backup, archive, and log server.
28-
console - serial console access. Used to start, stop, and debug
29-
a host.
30-
db - SQL server.
31-
dns - authoritative DNS.
32-
mx* - incoming email.
33-
search - search middleware (Elasticsearch).
34-
smtp* - outgoing email.
35-
www* - http over SSL.
21+
db - SQL server
22+
dns - authoritative DNS
23+
mx* - incoming email
24+
smtp* - outgoing email
25+
www* - http over SSL
3626

3727
groups marked with an asterisk (*) use public SSL certificates.
3828

39-
4029
The following variables are available:
4130

42-
backup_server - database dump, log, static file, and email backup.
43-
console_server - serial console (for grub), installer (with live cd),
44-
reverse DNS, and SSH key management.
45-
db_server - SQL server.
46-
dns_server - authoritative DNS server.
47-
mx_server - incoming mail server.
48-
search_server - search middleware.
49-
smtp_server - outgoing mail server.
50-
www_server - http.
31+
db_server - SQL server
32+
dns_server - authoritative DNS server
33+
mx_server - incoming mail server
34+
smtp_server - outgoing mail server
35+
www_server - http/s
5136

52-
When a host group has more than one hostname, the _server variable
53-
contains the authoritative name for the hosted sevice.
54-
55-
This playbook tries not to distinguish between host variables and
56-
group variables.
37+
When a host group has more than one hostname, the _server variable contains the authoritative name for the hosted sevice.
38+
This playbook tries not to distinguish between host variables and group variables.
5739

5840
https://docs.ansible.com/ansible/latest/intro_inventory.html
5941

6042

61-
#### Tags
62-
63-
The following tags can be used to limit tasks in a playbook:
64-
65-
pkg - install operating system packages (deb or rpm).
66-
user - create or revoke system administrator accounts
67-
and public SSH keys.
68-
69-
A role name can be used as a tag. When given, the tasks in that role
70-
will be run.
71-
72-
https://docs.ansible.com/ansible/latest/playbooks_tags.html
73-
74-
75-
Roles
76-
-----
43+
## Roles
7744

7845
mariadb - SQL database.
7946
lobsters - web application.
8047
nginx - http proxy and SSL termination.
8148
sysadm - accounts and ssh shell acess for system administrators.
8249
postfix - MX and smtp server.
83-
puma - App server
50+
lobsters-puma - App server
8451

8552
https://docs.ansible.com/ansible/latest/playbooks.html
8653
https://docs.ansible.com/ansible/latest/playbooks_reuse_roles.html
8754

8855

89-
#### SSH Keys
90-
91-
To use this playbook, you'll need an account in the sysadm role
92-
along with an SSH key pair.
93-
56+
## SSH Keys
57+
58+
To use this playbook, you'll need an account in the sysadm role along with an SSH key pair.
59+
60+
61+
## Setup Notes
62+
63+
This is a rough checklist for turning a new Ubuntu LTS VPS into a running instance of Lobsters.
64+
If you're familiar with Linux sysadmin and Rails it should be pretty self-explanatory.
65+
You can drop by `#lobsters` on Freenode if you have questions.
66+
67+
68+
```
69+
ssh root@now box
70+
set -o vi
71+
apt-get update
72+
apt-get upgrade
73+
reboot # will almost certainly be a new kernel
74+
apt-get install certbot vim fd-find tree net-tools
75+
append to /root/.bashrc
76+
alias fd=fdfind
77+
alias vi=vim
78+
set -o vi
79+
adduser pushcx
80+
cd ~pushcx
81+
cp -a /root/.ssh .
82+
chown -R pushcx:pushcx .ssh
83+
addgroup pushcx admin
84+
addgroup pushcx sudo
85+
mkdir /tmp/ansible
86+
chmod 777 /tmp/ansible
87+
time ansible-playbook -K prod.yml # should get an error about connecting to database
88+
vi ~lobsters/.bashrc, append 'export RAILS_ENV=production'
89+
mkdir -p /srv/lobste.rs/http/tmp/pids /srv/lobste.rs/http/tmp/cache
90+
chown -R lobsters:lobsters /srv/lobste.rs/http/tmp
91+
mysql -u root
92+
create database lobsters;
93+
select sha1(concat('mash keyboard', rand()));
94+
create user lobsters@'localhost' identified by "[hash]"; # may need to be @'%' for any host, an ip, etc
95+
grant all privileges on lobsters.* to 'lobsters'@'localhost'; # match host from prev
96+
create /srv/lobste.rs/http/config/database.yml
97+
create /srv/lobste.rs/http/config/initializers/production.rb
98+
create /srv/lobste.rs/http/config/secrets.yml
99+
bundle exec rails credentials:edit to create secret key base
100+
chown -R lobsters:lobsters /srv/lobste.rs/http/config
101+
echo "your@email.com" > /root/.forward
102+
run ansible again to deploy code + build assets
103+
reboot again # to see everything comes up properly automatically
104+
```

0 commit comments

Comments
 (0)