streampunk.cc Ansible config
This playbook will install autoradio on a cluster of machines, along with the necessary infrastructure (etcd, logging, monitoring and alerting).
Setup
Before running the playbook against test or production environments, you'll need to ensure Ansible is set up properly.
ansible.cfg
Use ansible-playbook -i hosts.ini to control the production hosts. But first you're going to need a proper ansible.cfg file. There are a few important settings that need to be present:
- since some templates use facts from other hosts, if you ever want to run the playbook on a subset of hosts you're going to need a fact cache
- preferably install Mitogen and set the strategy to mitogen_linear
Something like the following should do (change the Mitogen path to reflect your own installation):
[defaults]
nocows = 1
strategy_plugins = /usr/local/mitogen-0.2.9/ansible_mitogen/plugins/strategy
strategy = mitogen_linear
force_handlers = True
fact_caching = jsonfile
fact_caching_connection = .fact-cachs
[ssh_connection]
ssh_args = -C -o ControlMaster=auto -o ControlPersist=120s
control_path_dir = ~/.ansible/cp
control_path = %(directory)s/%%h-%%r
pipelining = True
ANSIBLE_VAULT_PASSWORD_FILE
Decrypt the ansible-vault passphrase from the secrets storage, and write it into a file named .ansible_vault_pw in this same directory.
Then
$ export ANSIBLE_VAULT_PASSWORD_FILE=.ansible_vault_pw
Configuration
There are some mandatory configuration variables that need to be set in group_vars/all/vars.yml (which ships with defaults that are only appropriate for the Vagrant test environment). They are:
- public_domain - the DNS domain to use to host the streaming infrastructure
- admin_emails - a list of email addresses that will receive alerts and other administrative spam
- smtp_server - SMTP server to use for outbound email
- smtp_auth_user - username for SMTP authentication
- smtp_auth_password - password for SMTP authentication
Networking
The playbook supports split networking scenarios, where the IP address used by the public is different than the one used by peers to communicate among themselves.
For every host, the Ansible variables public_ip and peer_ip must be defined. There are two ways to do this:
- you can specify these values explicitly in the Ansible inventory for each host, or
- Ansible can auto-detect the IP addresses if you specify the network interfaces used for public/peer networking with the public_network_interface and internal_network_interface variables.
By default, public_network_interface and
internal_network_interface are both set to ens6
, which happens to
work well with the test Vagrant setup.
Inventory Groups
If you are using the default site.yml playbook, there are some host groups that will need to be defined in the Ansible inventory:
- etcd - hosts that will be running etcd
- monitor - hosts that will be running the monitoring stack
You should have at least 3 hosts in the etcd group, and at least 2 in the monitor group (for redundancy).
Testing
To test locally (with Vagrant and Virtualbox):
$ vagrant up
$ export ANSIBLE_HOST_KEY_CHECKING=False
$ ansible-playbook -i hosts-vagrant.ini site.yml
This will start a 3-node autoradio cluster, with IPs 10.236.82.10-12. The cluster will be using autoradio packages from the default Debian repository.
Testing with local autoradio builds
If the source_repository_path Ansible variable is defined to point at the autoradio source repository, the playbook will install locally-built autoradio binaries. This can be very useful to quickly test local uncommitted changes:
$ ansible-playbook -i hosts.ini \
-e source_repository_path=$HOME/go/src/git.autistici.org/ale/autoradio \
site.yml
Test stream
The test-source.yml Ansible playbook can be used to quickly setup a stream and an associated source for testing purposes. Use the stream_name Ansible variable to set the name of the stream to be created:
$ ansible-playbook -i hosts.ini \
-e stream_name=/test.ogg \
test-source.yml
Then it's easy to create test loads with, e.g., autoradio's radiobench utility:
$ go run git.autistici.org/ale/autoradio/cmd/radiobench \
-n 100 http://10.236.82.10/test.ogg
will start 100 listeners on the stream just created above.