About me • Werner M. Krauß • Located in Hallstatt, Austria • wmk on IRC / github / stackoverflow • PHP since 1998 • Freelancer since 2006 (netwerkstatt) • SilverStripe since 2009
Overview • What is this thing called ansible? • What is debops? • What is deployment? • How can we put this things together and deploy a SilverStripe site with it?
Ansible scales down • Of course you can manage tons of servers • Configuring a single node is also easy • "Simple things should be simple, complex things should be possbile" (Alan Kay)
Requirements • Control Machine: – Python 2.6 or 2.7 – gcc (for installing some python packages) – Linux, OSX, any BSD…. – Windows isn‘t supported • Managed Node: – SSH – Python 2.4 or later
What is debops? • Your Debian-based data center in a box • Collection of Ansible playbooks • Scalable • 80+ highly extensible roles • Some custom scripts • Since October 2013 • Small but very helpful community
What is deployment? Deployment is a word, often used by the military, for sending troops into duty. A soldier could be part of a deployment to the Middle East. Deployment refers to assigning people to serve in various locations, especially soldiers and other military personnel. www.vocabulary.com/dictionary/deployment
What is deployment? #2 In its IT context, deployment encompasses all the processes involved in getting new software or hardware up and running properly in its environment, including installation, configuration, running, testing, and making necessary changes. whatis.techtarget.com/definition/deploy
Deploying SilverStripe • Check if all required packages are installed – nginx, mysql, memcache etc… • Set up a virtual host • Create needed directories • Create database • Create _ss_environment.php or mariaDB
Deploying Silverstripe #2 • Copy files (checkout from git) • Install composer packages • Import database and assets • Run dev/build • Optional: setup cron tasks • …and anything you need for a happy site
Basic server setup • Depops bootstrap • Setup ssh key on the machine • Add host to the webserver, php (and db) groups in inventory • Configure group vars
Create project user - name: create project user user: name: '{{ silverstripe_user }}' group: '{{ silverstripe_group }}' comment: 'project user for {{ silverstripe_project }}' home : '{{ silverstripe_user_home}}' state: present append: True system: True some variables defined before
Install composer Command line: ansible-galaxy install loranger.debian-composer Playbook: - role: loranger.debian-composer downloads the role installs composer and keeps it updated when you run the playbook
Configure nginx • Basically role configuration • Sets up redirect from e.g. from example.com to www.example.com • Setup virtual host and configure it for SilverStripe
- name: checkout project repository in webroot git: repo='{{ silverstripe_repo_url }}' dest='{{ silverstripe_path_wwwroot }}' accept_hostkey=yes tags: deploy-update - name: set file ownership file: > path={{ silverstripe_path_wwwroot }} recurse=yes owner='{{ silverstripe_user }}' group='{{ silverstripe_webserver_user }}' tags: deploy-update tags are useful if you want to run a set of tasks only
Import Data #2 • Note to myself: SSPak is made for this https://github.com/silverstripe/sspak • But copy, mysql and unarchive modules are good examples
Run the playbook debops silverstripe-demo.yml -e silverstripe_db_dump=/path/to/demo.sql -e silverstripe_assets_dump=/path/to/assets.tgz define a variable on the command line name of the playbook
Is there a role for it? • Silverstripe deploy role is in development • Capistrano like deploy with releases: f500 project_deploy https://galaxy.ansible.com/list#/roles/732