Services Blog Français

open source software playlabs

| by jpic | python ansible devops playlabs

I have just rewritten the README for playlabs, my ansible wrapper command. Note that this software is still in pre-alpha/planning stage and should only be used in production by seasoned haxors. # Playlabs: the obscene ansible distribution DISCLAMER: maybe it even works for you, but that’s far from garanteed so far. I love ansible most of the time, the rest of the time it makes me feel like it deserves better UX. Playlabs unfrustrates me: - provides a CLI to generate ansible-playbook commands, - works without inventory with options passed on the CLI, - also works with an inventory, that it standardizes, - able to combine both of the above, - provides a generic “project” role for my custom projects CD, that provides with nginx-proxy, letsencrypt-companion, netdata monitoring, sentry, etc - 1-click galaxy role install, role sub-task execution, chaining, etc, using generic playbooks and other obscenities - provides a command to setup ansible host dependencies (enforcing python3), my user with my key and passwordless sudo and disable root and password ssh access (my way or the highway !) - also supports k8s, but I won’t prescribe it until you need HA A more extensive and user-friendly documentation is in the docs sub-directory of playlabs and online @ thanks to RTFD :) ## Install playlabs This would install in the ~/src/playlabs directory: pip3 install –user –editable git+ Run the ansible-playbook wrapper command without argument to see the quick getting started commands: ~/.local/bin/playlabs # or: echo ’export PATH="$PATH:$HOME/.local/bin"’ » ~/.bashrc Then, install your user with your public key, passwordless sudo, and secure SSH for the playlabs install command to work. Playlabs provide two ways. ### Vagrant/VirtualBox In the git directory of playlabs, you can run vagrant up to have a VM on that you can ssh to with sudo access: cd ~/src/playlabs vagrant destroy -f vagrant up ssh date playlabs install docker,k8s @ ### Bare host with ssh The playlabs init command can setup your user for you: # example with root acces playlabs init root:aoeu@ # all options are ansible options are proxied playlabs init @ –ask-become-pass # example with a typical openstack vm playlabs init ubuntu@ –ask-become-pass Now you should be able to install roles. ## Deploy a docker image ### Without inventory You can now deploy a container for a custom image, it will create a project-staging container by default: playlabs deploy @ image=betagouv/mrs:master This time with more variables and in ybs-hack instead of project-staging: playlabs deploy @ image=betagouv/mrs:master prefix=ybs instance=hack plugins=postgres,django,uwsgi backup_password=foo env.SECRET_KEY=itsnotasecret ### With inventory To generate a starter inventory where you can store variables such as users, keys, passwords with ansible-vault, etc: playlabs scaffold ./your-inventory Then from CI of a project, you can auto-deploy the ybs-hack instance from above as such (it will pickup the ybs_hack_* variables from the inventory): playlabs deploy @ prefix=ybs instance=hack instance=$CI_BRANCH image=$CI_REGISTRY_IMAGE:$CI_COMMIT_SHA ## Installing roles You will probably want to monitor your server: playlabs install netdata @ You could also install galaxy roles that contain a dot, in which case playlabs will automatically download it if necessary: playlabs install ferrarimarco.virtualbox @ You could also execute a specific role task file instead of main.yml, if your role name contains a slash: # run k8s/tasks/users.yml instead of k8s/tasks/main.yml # in the CI of your inventory for example to react to changes ? playlabs install k8s/users @ Note that the dot and slash notations should be compatible. You can also execute multiple roles at once if you separate them by comma: playlabs install netdata,ferrarimarco.virtualbox,k8s/users @ You can set ansible variables directly on the command line. If you use dot in variable name, it will build a dict, ie.: playlabs install netdata @ example=lol # will generate the extra ansible-playbook options: ansible-playbook … -e example=lol -e ‘{“foo”: {“bar”: “test”}}’ ## Kubernetes We also have k8s support, but beware that it’s not compatible with the deploy command, that relies on nginx-proxy and its letsencrypt companion, it’s currently in-development and not tested in production, but still pretty cool: playlabs install k8s @ # or, run k8s/tasks/init.yml instead of k8s/tasks/main.yml to reset a cluster playlabs install k8s/init @

They trust us