Skip to content

Commit 4cf963d

Browse files
authored
Merge pull request #83 from madic-creates/patch-2
Update Ansible task template guide and added Task Template overview
2 parents 0970301 + 8df3a41 commit 4cf963d

File tree

6 files changed

+55
-8
lines changed

6 files changed

+55
-8
lines changed

src/.gitbook/assets/ansible_1.png

79.9 KB
Loading

src/.gitbook/assets/ansible_2.png

74.8 KB
Loading

src/SUMMARY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
* [Runners 🅿](./user-guide/projects/runners.md)
4949
* [Task Templates](./user-guide/task-templates/README.md)
5050
* [Ansible](./user-guide/task-templates/ansible.md)
51-
* [Terraform/OpenTofu](./user-guide/task-templates/terraform/README.md)
51+
* [Terraform/OpenTofu](./user-guide/task-templates/terraform.md)
5252
* [Workspaces](./user-guide/task-templates/terraform/workspaces.md)
5353
* [States 🅿](./user-guide/task-templates/terraform/states.md)
5454
* [Shell/Bash scripts](./user-guide/task-templates/bash.md)

src/user-guide/task-templates/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Task Templates
22

3-
Templates define how to run an Ansible Playbook. The template allows you to specify the following parameters:
3+
Templates define how to run Semaphore tasks. Currently the following task types are supported:
44

55
* Playbook repository
66
* Playbook filename

src/user-guide/task-templates/ansible.md

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,61 @@
55

66
# Ansible
77

8-
Using Semaphore UI you can run Terraform code. To do this, you need to create a **Terraform Code Template**.
8+
Using Semaphore UI you can run Ansible playbooks. To do this, you need to create an **Ansible Playbook** Template.
99

10-
1. Go go Task Templates section and click the **New Template** button.
10+
1. Go go **Task Templates** section, click on **New Template** and then **Ansible Playbook**.
1111

12-
![](<../../.gitbook/assets/terraform_1.webp>)
12+
![](<../../.gitbook/assets/ansible_1.png>)
1313

14-
2. Set up the template and click the **Create** button.
14+
2. Set up the template.
1515

16-
![](<../../.gitbook/assets/terraform_2.webp>)
16+
The template allows you to specify the following parameters:
1717

18-
3. You can now run your Terraform code.
18+
* Repository
19+
* Path to playbook file
20+
* Inventory
21+
* Variable Groups
22+
* Vaults
23+
* and much more
24+
25+
![](<../../.gitbook/assets/ansible_2.png>)
26+
27+
An ansible-playbook template can be one of the following types:
28+
29+
* [Task](#task)
30+
* [Build](#build)
31+
* [Deploy](#deploy)
32+
33+
### Task
34+
35+
Just runs specified playbooks with specified parameters.
36+
37+
### Build
38+
39+
This type of template should be used to create [artifacts](https://en.wikipedia.org/wiki/Artifact\_\(software\_development\)). The start version of the artifact can be specified in a template parameter. Each run increments the artifact version.
40+
41+
![](<../../.gitbook/assets/template\_new\_build\_ipad (1).png>)
42+
43+
Semaphore doesn't support artifacts out-of-box, it only provides task versioning. You should implement the artifact creation yourself. Read the article [CI/CD](../../administration-guide/cicd.md) to know how to do this.
44+
45+
### Deploy
46+
47+
This type of template should be used to deploy artifacts to the destination servers. Each `deploy` template is associated with a `build` template.
48+
49+
![](../../.gitbook/assets/template\_new\_deploy\_ipad.png)
50+
51+
This allows you to deploy a specific version of the artifact to the servers.
52+
53+
### Schedule
54+
55+
You can set up task scheduling by specifying a cron schedule in the template settings. Cron expression format you can find in [documentation](https://pkg.go.dev/github.com/robfig/cron/v3#hdr-CRON\_Expression\_Format).
56+
57+
![](../../.gitbook/assets/template\_schedule.png)
58+
59+
#### Run a task when a new commit is added to the repository
60+
61+
You can use cron to periodically check for new commits in the repository and trigger a task upon their arrival.
62+
63+
For example you have source code of the app in the git repository. You can add it to **Repositories** and trigger the Build task for new commits.
64+
65+
![](../../.gitbook/assets/template\_schedule\_commit.png)

0 commit comments

Comments
 (0)