I have previously written about deploying Ghost using Terraform, Ansible, and Ghost CLI. In that last post I updated my existing repo to do a fresh install of the Ghost using the tools mentioned. Now I will be enhancing the same project with an update option.
Ansible role changes
I added two main features to the custom Ansible role, tags and update tasks. The tags I used to control which steps are run, and the new tasks I added to make sure the ghost instance can be properly updated in a relatively resource constrained environment.
The main changes can be seen in the main.yaml task file above. The first three tasks have Ansible reserved tag, always. As the tag implies, these tasks will always run regardless of the other tags I specify in the command. The Install Ghost task has a custom freshinstall tag, and this will only run when I specify this tag in the command. And finally the new tasks, Stop Ghost, Update Ghost, and Start Ghost have the update tag, and these tasks will only run when this tag specified in the command.
So with these updates made to the role, I used the following command to update my Ghost instance.
The above command ran all the tasks tagged with always and update.
I created explicit tasks for stop, update, and start because of the resource constraints a server might have. The update will fail if there is not enough RAM on the server. If you bypass the memory check, the update will still fail due to insufficient resources to actually download and setup the new Ghost install.
So with that I now have a brand new install of Ghost, with all my data migrated, and an automated way to maintain the install the recommended way.