CI/CD
Semaphore supports build
and deploy
tasks.
Semaphore passes semaphore_vars
variable to each Ansible playbook which it runs.
You can use it in your Ansible tasks to get what type of task was run, which version should be build or deployed, who ran the task, etc.
Example of semaphore_vars
for build
tasks:
Example of semaphore_vars
for deploy
tasks:
Build
This type of task is used to create artifacts. Each build task has autogenerated version. You should use variable semaphore_vars.task_details.target_version
in your Ansible playbook to get what version of the artifact should be created. After the artifact is created, it can be used for deployment.
Example of build
Ansible role:
Get app source code from GitHub
Compile source code
Pack created binary to a tarball with name
app-{{semaphore_vars.task_details.target_version}}.tar.gz
Send
app-{{semaphore_vars.task_details.target_version}}.tar.gz
to an S3 bucket
Deploy
This type of task is used to deploy artifacts to destination servers. Each deployment task is associated with the build task. You should use variable semaphore_vars.task_details.incoming_version
in your Ansible playbook to get what version of the artifact should be deployed.
Example of deploy
Ansible role:
Download
app-{{semaphore_vars.task_details.incoming_version}}.tar.gz
from an S3 bucket to destination serversUnpack
app-{{semaphore_vars.task_details.incoming_version}}.tar.gz
to destination directoryCreate or update configuration files
Restart app service
Last updated