|
1 |
| -Ansible module used by OSAS to deploy various middleman website. Currently used to validate the strategy |
2 |
| -of using common repository for the various ansible modules. |
| 1 | +Ansible module used by OSAS to deploy various middleman website. While |
| 2 | +working, the role is still being written, as seen by the TODO list at the end |
| 3 | +of this document. |
| 4 | + |
| 5 | +# Example |
| 6 | + |
| 7 | +The role requires a working web server somewhere, if possible managed by ansible |
| 8 | +as well. In the simplest invocation, this should be something like this: |
| 9 | + |
| 10 | +``` |
| 11 | +$ cat deploy_builder.yml |
| 12 | +- hosts: webbuilder |
| 13 | + roles: |
| 14 | + - role: builder |
| 15 | + name: website_example_org |
| 16 | + git_url: "https://git.example.org/website.git" |
| 17 | + rsync_location: /var/www/html |
| 18 | + rsync_server: www.example.org |
| 19 | + rsync_user: rsync_user |
| 20 | +``` |
| 21 | + |
| 22 | +This will deploy the build of https://git.example.org/website.git by |
| 23 | +using rsync as rsync_user on www.example.org, copying in /var/www/html. |
| 24 | + |
| 25 | +The script will not sync if build failed, and will not send email (that's on the |
| 26 | +TODO list, see end of the file) |
| 27 | + |
| 28 | +# Handling multiple repositories |
| 29 | + |
| 30 | +In order to support multiple repositories, the script detect if |
| 31 | +submodules are used and track the latest commit for each and force update |
| 32 | +if needed. While that's not how submodules are supposed to be used, people |
| 33 | +often forget to update submodules and so we need to use this as a workaround. |
| 34 | + |
| 35 | +This cannot be turned off for now, but will be added as a option if needed. |
| 36 | + |
| 37 | +# Using with openshift |
| 38 | + |
| 39 | +The role can also be used with non managed services, such as openshift online v2. |
| 40 | +For that, you need to deploy the role without giving a `rsync_server` argument. |
| 41 | + |
| 42 | +Then, you need to make sure that `bundle exec middleman deploy` is able to push |
| 43 | +the website. In the case of openshift, this implies to let the key in ~/.ssh/$NAME.pub |
| 44 | +push to openshift, with £NAME replaced by the name given to the role. |
| 45 | + |
| 46 | +# Regular rebuild |
| 47 | + |
| 48 | +The role will rebuild the website on a regular basis, every 6h |
| 49 | +by default. This is not yet a option that can be changed. |
| 50 | + |
| 51 | +# Debug the build |
| 52 | + |
| 53 | +In order to debug a non working build, the easiest is to connect to the |
| 54 | +server as the non privileged user used to build (with ssh + sudo or su most of the time). |
| 55 | + |
| 56 | +Each website to build will have a directory serving as workspace for the build, that |
| 57 | +contains a status file of the form `status_$NAME.yml` |
| 58 | + |
| 59 | +``` |
| 60 | +$ cat status_website_example_org.yml |
| 61 | +last_build: '1467869767' |
| 62 | +last_build_commit: 819bcaef161706441f9a4477d664b67a3616049a |
| 63 | +last_build_human: Tue Jul 5 03:27:57 2016 |
| 64 | +submodule_commits: {} |
| 65 | +``` |
| 66 | + |
| 67 | +Then, the build script can be run with `/usr/local/bin/build_deploy.py -d -f -n ~/website_example_org.yml`, |
| 68 | +which would force a build (-f) without pushing (-n) with debug turned on (-d). |
| 69 | + |
| 70 | +# Missing features |
| 71 | + |
| 72 | +While being already used in production, several options are missing |
| 73 | +- notification of failure by sending a email |
| 74 | +- notification of the start of a build |
| 75 | + - either by publishing the logs |
| 76 | + - or by pushing a status file on the website |
| 77 | +- proper logging of error |
| 78 | +- handling automatically some errors (like rebuilding gems) |
| 79 | +- change the schedule of automated rebuild |
0 commit comments