Extending the Ansible Playbook for Training
This is a modal window.
The media could not be loaded, either because the server or network failed or because the format is not supported.
Formal Metadata
Title |
| |
Title of Series | ||
Number of Parts | 44 | |
Author | ||
License | CC Attribution 3.0 Germany: You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal purpose as long as the work is attributed to the author in the manner specified by the author or licensor. | |
Identifiers | 10.5446/60247 (DOI) | |
Publisher | ||
Release Date | ||
Language | ||
Production Place | Namur, Belgium |
Content Metadata
Subject Area | ||
Genre | ||
Abstract |
|
Plone Conference 202233 / 44
10
14
22
23
26
27
40
00:00
Directory serviceMultiplication signDisk read-and-write headIntegrated development environmentGastropod shellMenu (computing)CloningSocial classNeuroinformatikState of matterWave packetDifferent (Kate Ryan album)PasswordError messagePoint (geometry)BitFunction (mathematics)Server (computing)Revision controlConfiguration spaceUsabilityProjective planeCodeElectronic mailing listPresentation of a groupStudent's t-testLocal ringInstance (computer science)Process (computing)CAN busWindowCoefficient of determinationScripting languageMereologySoftware developerComputer fileKey (cryptography)Computer configurationArithmetic progressionInstallation artVirtual machineShape (magazine)VideoconferencingPhysical lawSet (mathematics)Figurate numberShared memoryType theoryMessage passingSource codeTask (computing)LoginGroup actionInformationLink (knot theory)CASE <Informatik>CodeSource codeXML
08:07
QuantumWorld Wide Web ConsortiumGamma functionInstant MessagingKey (cryptography)Metropolitan area networkWechselseitige InformationGEDCOMJohann Peter HebelLie groupNo free lunch in search and optimizationFront and back endsLine (geometry)Coma BerenicesInfinityAsynchronous Transfer ModeGame theoryComputer-generated imageryServer (computing)Insertion lossWindowSummierbarkeitDuality (mathematics)Library (computing)FingerprintServer (computing)Level (video gaming)Default (computer science)Group actionCloningLocal ringWebsiteCuboidParameter (computer programming)Instance (computer science)Scripting languageNormal (geometry)Declarative programmingInstallation artEmailRepository (publishing)Mobile appIntegrated development environmentFront and back endsSoftware developerProduct (business)CodeVirtual machineTablet computerMultiplication signSet (mathematics)Computer fileKernel (computing)DatabasePoint (geometry)Content (media)Gastropod shellProcess (computing)Task (computing)Computer architectureMenu (computing)Projective planeDevice driverArmDirectory serviceMedical imagingRight angleCompilation albumRevision controlBitConfiguration spaceDebuggerTouchscreenNeuroinformatikGraph coloringRadio-frequency identificationPhysical lawContext awarenessConnected spacePlanningGame theoryMultiplicationOrder (biology)Latent heatOntologyRemote procedure callElectric generatorGoodness of fitPiNatural language1 (number)Element (mathematics)GodProper mapEndliche ModelltheorieSource code
16:14
Maxima and minimaComputer-generated imageryServer (computing)Gamma functionMetropolitan area networkOpen setLibrary (computing)Numerical digitCache (computing)Boom (sailing)Menu (computing)GEDCOMMeta elementTwin primeWorld Wide Web ConsortiumLTI system theoryFront and back endsScripting languageComputer file2 (number)MereologyOrder (biology)Virtual realityMultiplication signVirtual machinePasswordType theoryGastropod shellExistenceElectric generatorDebuggerMessage passingParameter (computer programming)Level (video gaming)Personal identification numberFlagServer (computing)Computer architectureKey (cryptography)Medical imagingMultiplicationContext awarenessIntegrated development environmentCuboidError messageCloningRight angleDatabaseVolume (thermodynamics)Wave packetBranch (computer science)SynchronizationProjective planeSystem call1 (number)BuildingPoint (geometry)Product (business)Different (Kate Ryan album)ArmMobile WebTwitterPlanningNetwork topologyGroup actionBit rateLocal ringWordSource code
24:21
Turtle graphicsComputer animation
Transcript: English(auto-generated)
00:03
Hello everybody and welcome to my talk Extending the Ansible Playbook for Training. My name is Brian Davis I am formerly part of the WebLion crew at Penn State, past contributor to the Plone Symposium East conferences and you may have seen me there and currently working with Rick Opeka and some of the other folks on RebuildingPlone.org. I've been using Plone for quite a long time
00:27
version 0.98 circa 2002 so showing my age a little bit there, but once I started using Plone, I never looked back Sorry, I couldn't be there with you in Belgium today
00:40
But I learned a trick at my last conference Because like three people started their presentations this way so I thought maybe I could try it and see if it worked for me so What I want you all to do right now is close your eyes and Picture me being there in Belgium with you It's like the same thing. We'll be okay. I hope
01:04
What I want to show you guys today is the training deploy project I was a student last year at Errico Andres Volto and Plone Deployment course at the Plone conference and Having been away from Plone for a few years
01:22
Maybe because I didn't like the diazo I was looking for a more modern solution to jump right in to Plone 6 Perhaps something that was containerized Automated and lo and behold Errico's class was exactly what I was looking for So I ended up re-watching the video after class like 10 different times
01:42
So I could pause and rewind and kind of figure things out and really enjoyed it After the class I started to think how could we improve upon this? What could we add? Where did I struggle? What did I want to see? as an output from this and
02:03
How could I use it in my day-to-day work? And so I started to dig at the Ansible code a little bit and Found some things that may be Useful for somebody so I wanted to kind of share those with you today now I don't want to Repeat everything that was in Errico's course
02:23
But if you have been to Errico's course you will have a good start on what I'm going to talk about today And if you haven't this will be a quick kind of overview for you, so In the training deploy project which we use in the course what we're able to do is run an Ansible script to set up a
02:43
Docker deployment of Plone When I had first come to the class there was a list of prerequisites that needed to be installed and As the procrastinating developer that I am I didn't have any of those installed so I spent the early part of
03:00
The morning quickly typing on my computer trying to get everything installed and quickly fell behind in class The second thing that I noticed is when we got done we had a successful running local vagrant deployment of our Docker and I wanted to be able to push those directly to a remote source
03:23
So I wanted to look at how Docker did that and try to implement that in here With the with the code in training deploy project It is all based on a simple playbook file, playbooksetup.yaml. We can take a look at
03:43
How this was originally set up it is done in a linear fashion where everything is all right together in a common role and if you haven't Used Ansible before the concept of roles is that you can take many tasks and group them together into like a mini
04:01
playbook inside the playbook So that's kind of what I wanted to explore was is there a need or use for more than one playbook here? But as you can see in Ericos it just goes through and does the the apt install the pip install Some basic things that you'll need for setting up a Plone site, creating a Plone user, shell keys,
04:26
directory copying in the docker-compose.yaml file and The configuration for nginx and restarting nginx So what I did was I kind of took those and I broke those out into different roles
04:42
So looking over at the coding window if I remember which way to point here So in Ansible what I set up was four different roles Okay, now the first role we're going to talk about is setup host and what that does is install all of the prerequisites for you
05:00
once you have that you can then go in and Do the manual steps to create your Plone instance create your Volto instance and get those launched and running on your local machine So we'll take a look at that now the The initial Playbook as You can see here sets up a menu where you can build a development a local and a remote
05:25
okay, and the Once you choose one of those menu items it calls one of these three roles setup post setup local setup remote Okay There are some other things here in the initial playbook such as gathering some host facts from the host file
05:44
The host file is where you keep basically all your login information any Any access that you would need to any of the computers so So your shell port your host your Ansible user
06:01
And your shell keys now if you don't have shell keys installed you can use something called Ansible shell pass Which will allow you to type in your password manually However once you run this script for the first time it will install Shell keys for you, so you won't need it after the first time But if you already have shell keys set up you can go ahead and just link to them here
06:22
And then it will call them in that other script Now host facts is just set up to run on the BM Ansible host So if we look back here we can see that it does in fact set up the shell keys figure out what the host is what the user is and
06:40
Then create a vagrant provision if we choose option two which we're not so So that gets us through the initial playbook we'll go ahead and launch this now when you first start there is a make setup and a Make clean so the make clean just deletes
07:04
We can take a look at that here The Make clean just delete some directories if you've previously run this script before so you can start with a fresh environment And the make setup just calls the Ansible executable okay, so what I've done is adding make install
07:23
that goes ahead and runs the playbook Against the Against the server, so we're gonna make install Okay, and first it's gonna ask you for it become password now
07:40
This is just your pseudo password that you'll need for heightened privileges later on So we take that in it'll ask you for a node password. This is the password for your remote Node I have that in there in case you don't have the shell key set up Okay, and then it gives you those three menu items that we saw earlier
08:03
Okay, now what we're gonna. Do is we're gonna call the setup host role So the setup host role Goes ahead and and does some things to your local machine such as installing curl installing node Python 3 dev
08:22
Dockers GPG keys connecting to the Docker repository Installing Docker Docker compose and then also creating the Docker group if it doesn't exist and Adding your user to that group now normally you would have to log out and log back in but we can add a another task
08:44
To this playbook that just says reset the shell connection, so we don't have to log out and log back in What you also see in this file is setting up the local environment for For local deployments, so downloading VirtualBox downloading some libraries
09:02
Some dependencies it will also need to set up your Linux image and your Linux header for the kernel Which I'm not going to do the local Install for this one. I'm actually running on a Raspberry Pi so grabbing the headers and the image for that were a little different
09:22
But this should give you a good example You also want to install VirtualBox here and load the vbox driver kernel module, okay, so So yeah, we can go ahead and run that we just press 1 and
09:41
You can watch all the pretty colors scroll through the screen Now this is going to run a lot faster on my computer than it will on yours because I've run this before this is Kind of like one of those TV shows where they bake a cake beforehand And then they show you the cake afterwards so that they can speed up for time. I baked some cakes earlier
10:01
I've run this earlier, so it does run a little bit faster but you can see it's going ahead and it's downloading the node installing curl everything that we just talked about and When this is done you will have a local environment Ready to go Okay, now a lot of this is similar like you see we're installing via app and via
10:24
Pip and stuff like that a lot of this is similar to Kim's clone in the box Where you're doing all of this through a a makefile, okay? I've used Kim's clone in the box before it works great It is built in a stack script that you can push directly to Linode
10:43
And as you can see here, it's the same kind of idea. We are apt to get installing the things that we need We are setting up nginx We are setting up the docker-compose.yaml Restarting nginx
11:01
Running the docker-compose up Things like that. How this differs is that In using the this Ansible playbook you can actually create three levels of development So you can set up a development server a staging server and a production server I like to run the staging on the local push the remote to a production and then use my machine for development
11:24
this way I can Install a new theme, install a new package Without having to touch my production environment, and then just push when I'm ready so So you can see our playbook is all finished here now, so we have the local
11:42
environment installed so the next step is that we're going to go ahead and Do the manual steps that are found in the documentation right? So this is just setting up our back-end setting up our front-end, so we cd into the back-end directory. We do a make build
12:02
I will I Will mention to you here in the back-end makefile that This does a at docker build Image name dockerfile, okay, so if you're installing on a raspberry pi
12:24
This is on an ARM 64 architecture So if you want to push it to an AMD 64 architecture or an x86 architecture you need to do a multi-arc build So there is some documentation on how to do that that you can find online. You'll have to set
12:43
an arg argument a argument yes and an arch argument and Declare that you want to build it specifically for the AMD 64 architecture, so So yeah, so we're setting up our clone. We're cd-ing into back-end and make build
13:03
It's going to go ahead and build that clone instance now, and then we run make start to launch it We go in we do our normal clone setup adding a site adding default content if you need it and We'll stop the process now if you don't want to set up that default content
13:21
You can also just import an old database at this this point Now now is a good time to do that if you're installing any kind of theme You'll want to do that in the next step Installing like a volto theme or something so So once we have that we move into our front end Set up and the first thing the actually the npm init yo clone volto. I've had better luck with the
13:48
Yo, clone a generator, so I've been using that recently But it just asks you what you want to call your setup if you want to install any add-ons I think in the the docs here I have to install slate, but I think slate is the install by default if I'm not mistaken so
14:06
If you don't want to install any add-ons you could just say false You can also change the the volto version in here You can also change the clone version in the backend code all that's very easy
14:20
So if you're updating to the next next version, and then once we have that set up We'll CD into the front end directory and compile with yarn Okay now Again, I have that Previously done and ready to go because that does take some time
14:41
and then What we do is we make start images for anything when we're on local make release images for anything we want to run Remote okay, so to deploy now to deploy Remote and local are pretty similar right so we can use some similar files
15:02
So this is where the fourth role you may have noticed there was three menu items and four roles This is where the fourth role comes in so this is setup client, okay? This gets called on either local or remote, and this does the basic setup of your Docker container, so this is installing packages like nginx
15:22
pip installing packages like Docker, okay Creating the clone user creating the project directory the same thing that we saw in Erica's initial setup copying in the configuration And you can see here. We're copying in the exact these actually are the exact same file
15:42
They're duplicated because you needed one in each directory For that to work, but just based on when variable there which host to call the remote or the local Go ahead and copy in the nginx file and Restart nginx so once that is done Then it will kick it over to either whichever you've chosen the local or the remote
16:05
so the the remote deployment and The local deployment are very similar except the local deployment when you do the Docker create
16:20
Docker create context the context is the Local vagrant box okay when you do the remote Here we are Docker contacts creating To a remote host and a remote port again pulled in by our host file
16:41
so That's basically how that works There is a pool and a compose up that will send that To docker hub so as you can see Earlier today. I pushed the example for this talk the plunk on front end and plunk off back end to my docker
17:05
Hub you will have to log in to docker from your command line once To authenticate and then you'll be okay with that So once they're pushed to docker now we can deploy them So we just come back into the script we've run it again make install
17:24
Type in our password again Okay, and this time we just choose three and as you can see that's going ahead and running the
17:40
Steps we just talked about So when this is done What we should have on a remote machine is so it's doing them the pool and the up now and
18:09
There are a few things that you should watch out for here I Had some issue with the order of an install in the script, so I think I have everything in the right order, but
18:22
But take a look at that the as you can see it's finished now, so I think we're good We log into our remote and as you can see 31 seconds ago 36 seconds ago both of the docker containers were launched So yeah, that's that's it in a nutshell
18:43
Like I said some of the issues I ran into the hardest part was just kind of figuring out the order of install some things needed to be installed before the Ansible script ran we can look at that in the Main make file here you can see I installed Python 3 virtual environment PIP shell pass
19:02
Just in my local machine to be able to run the Ansible And then figuring out where exactly to put things in the Ansible script one of the things I had a hard time figuring out where to put was the generation of the shell keys Because I wanted it to be able to work multiple times not just the first time so
19:22
Doing a check that that shell key exists. It doesn't exist recreating it We're sending it over with a shell copy ID. I had to be all put in the right spots I think I have it right, but if anybody has any better experience with that I'm all ears the Some of the other things that I ran into
19:44
Were that What was falling on the Raspberry Pi like I said you have to build a multi architecture image So figuring how to do that if you look at the
20:02
Make file for oh, no it is in the like so the back end make file or the front end make file You can see here Docker build What I use was a flag called
20:21
architecture argument to put that in there you may also have to raise your timeout On your yarn builds because this can take a while So that is something to watch out for I also had a pill pin century on a Raspberry Pi build
20:40
I was able to find a recommendation by Fred That was very helpful on that, but that's kind of going on on a different topic the The actual playbook here that we're running You Can use this to set up like I said three different environments a local a staging and a shell
21:05
And what you can do then is you can sync all of those Databases Just by mounting the volume right and making accessible by all three machines. What I will warn you is that It will work, but you should try to stay editing in one place, okay?
21:25
so if you're Using like the staging local just use it for installing new packages installing a theme Stuff like that and kind of keep your editing at the the production, so you don't run into syncing errors. I have run into that
21:40
before But yeah That's how the playbook works. It's kind of interesting, and I know there was a lot of work done on the playbook for clone 5 If you guys have looked at this
22:01
So the Ansible Plone server Would install for Plone 4.3 or Plone 5 and I think kind of this here could replace that so I know I kind of built the branch in the Training deploy project called Ansible full stack if you want to check it out
22:24
However, I think it can almost work as a standalone thing because maybe you don't want to install everything in the training course But you want to have an automated environment like this That's where this could come in handy So I think a lot of this can be used for the Plone 6 playbook, and there was also a lot of great work done on
22:44
Additional roles to install more things on your server to go alongside Plone I haven't messed with a lot of these, but I'm assuming most of them still work There are things like installing
23:01
Logwatch installing Munin installing Varnish things like that so I think there's a lot of kind of possibilities there It's something I'm interested in working on if it's something you're interested in working on please get a hold of me You can find me Faustin on discord or Faustin at gmail.com and
23:22
You know if I could get people together for a sprint to work on this that that would be great I know a lot of the people that were involved with the Plone 5 playbook are still heavily involved with Plone So maybe I just haven't talked to some of the people and heard their ideas But if you guys would like to organize a sprint after the conference
23:42
Or in the future I would be totally open to that and Seeing how we could improve this for Plone 6, so I hope you guys enjoyed my talk today. That's that's Ansible and Docker and Plone all in in harmony and
24:01
Yeah, I hope to see you all in the Plone world. Thanks for listening everybody. Oh by the way, yes ha Shout out for Plone Symposium Midwest. Yes, make sure I get into the thing here Yes, but thank you guys and enjoy the rest of your conference. Thanks for listening