You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: services/tower.md
+67-2Lines changed: 67 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -58,6 +58,73 @@ To update the Prancible inventory:
58
58
59
59
## Adding templates to Tower
60
60
61
+
If the playbook you want to run in Tower already exists in the princeton_ansible repository, you can easily create a template for it.
62
+
63
+
If you are working on a new playbook, and you want to test it in Tower, skip down to the section on `Creating a template for a new playbook`.
64
+
65
+
### Creating a template for an existing playbook
66
+
67
+
If your playbook already exists in the princeton_ansible repo, you can copy an existing template in Tower, then edit it to do what you need. Copying gives you the correct Inventory, Project, Execution Environment, and likely also the credentials you need.
68
+
1. In the Templates view, next to the template you want to copy, select `Copy template` on the far right (a pair of pages). Your copy will show up just below the existing record, with a timestamp to differentiate it from the original template.
69
+
2. Edit your copied template by selecting `Edit Template`.
70
+
3. Change at least these attributes:
71
+
a. name
72
+
b. description
73
+
c. playbook
74
+
4. If you want to allow the user to provide standard Ansible parameters (for example, `Limit` or `Source Control Branch` or `Verbosity`), select the `Prompt on launch` box above those entries.
75
+
5. Click `Save` to save your changes.
76
+
77
+
#### Adding or changing credentials
78
+
79
+
All templates must include the Prancible Vault credential, which supports decrypting vaulted variables at runtime. Most templates also need the Tower's Own ed25519 credential, which allows SSH access to our VMs. If you did not copy an existing template, you need to add the basic credentials. Depending on what your playbook does, it may need other credentials as well.
80
+
81
+
To add or change credentials:
82
+
1. Edit the Template.
83
+
2. In the `Credentials` section, delete any existing credentials you do not want or need.
84
+
3. To add credentials, click on the magnifying glass. By default you will see `Machine` credentials (usually Tower's Own ed25519).
85
+
3. Select the credential TYPE (Vault for the Vault cred, Machine for the SSH cred, etc.),then select the specific credential.
86
+
4. Repeat until you have all the credentials you want or need, then click on `Select` to add them all.
87
+
88
+
The `Edit Details` screen shows you all the Credentials that are associated with the template. If they are correct, click on `Save` to save your changes to the template.
89
+
90
+
#### Adding or changing surveys
91
+
92
+
If you want to pass variable values at runtime (for example, `runtime_env`), add one or more Surveys to your Template. If your new template is a copy of an existing template, it will include the surveys from the original template.
93
+
94
+
To add or change surveys:
95
+
1. If you have been editing your template, save your changes. Otherwise, click on the name of the template you want to add surveys to.
96
+
2. Switch from the `Details` tab to the `Survey` tab.
97
+
3. If you are changing a survey (for example, in a template you created by copying), click on any survey to edit it.
98
+
4. If you are adding one or more surveys to a new template (or if the template you copied had no surveys), click on `Add`.
99
+
5. Fill in the fields. The `Question` is what the user will see in Tower when running the template. The `Answer variable name` must match a variable in the playbook itself. Choose the type of answer, whether the question is required, whether there is a default value. When everything is ready, click on `Save`.
100
+
6. Repeat for every variable value you want users to provide at runtime.
101
+
7. Once your surveys are all configured, make sure the `Survey Enabled` button is turned on.
102
+
103
+
### Adding schedules
104
+
105
+
If you want to run the template on a regular cadence, automatically, add a Schedule to your template. A scheduled job runs the selected template with defined variables at a defined, recurring time. Each template can have multiple Schedules.
106
+
107
+
Note: Please set scheduled jobs to run in the evening or overnight so they do not interfere with morning maintenance or with urgent activity (for example, deploying a bugfix) on Tower during regular working hours. You can see a list of existing scheduled jobs ordered by start time by selecting `Schedules` from the main left nav.
108
+
109
+
To add a schedule:
110
+
1. If you have been editing your template, save your changes. Otherwise, click on the name of the template you want to add surveys to.
111
+
2. Switch from the `Details` tab to the `Schedules` tab.
112
+
3. Click `Add` and fill in the parameters.
113
+
a. Provide a descriptive name - for example "Thursday TigerData production build" or "Daily catalog staging deployment".
114
+
b. If your template has Surveys or Prompt on Launch options, the Schedule will pick up default values for those. If you want to use non-default values, click on `Prompt` and fill in the values you want for the particular recurring job.
115
+
116
+
#### Adding notifications
117
+
118
+
If you want a slack message when the template starts to run, succeeds, or fails, add one or more notifications to your template. Notifications can only be created globally, but each one can be turned on or off for each template in Tower.
119
+
120
+
To enable an existing notification:
121
+
1. If you have been editing your template, save your changes. Otherwise, click on the name of the template you want to add surveys to.
122
+
2. Switch from the `Details` tab to the `Notifications` tab.
123
+
3. Turn on the conditions you want for your notification.
124
+
4. To create a new notification type, select `Notifications` in the main left nav (in the Administration section). Note that all templates have access to all notification types.
125
+
126
+
### Creating a template for a new playbook
127
+
61
128
You cannot build a template off a playbook until that playbook exists in the main branch. In other words, you cannot test a playbook in a Tower Template while it only exists in a PR or on a branch. If you want to test a playbook from Tower:
62
129
1. Merge a minimal version of the playbook into the main branch.
63
130
2. Update the Prancible project.
@@ -66,8 +133,6 @@ You cannot build a template off a playbook until that playbook exists in the mai
66
133
5. Create a new branch for changes to the playbook.
67
134
6. Launch the template and select the new branch to run with the latest changes to the branch.
68
135
69
-
All templates must include the Prancible Vault credential. Most templates also need the Tower's Own ed25519 credential. When you add credentials to a template, select the credential TYPE (Vault for the Vault cred, Machine for the SSH cred) first, then the specific credential. You can add more than one credential at once if you want to.
70
-
71
136
## Adding repos to the Deploy Rails template
72
137
To add a new code repository to the Deploy Rails template, log into ansible tower and [then update the survey](https://ansible-tower.princeton.edu/#/templates/job_template/13/survey)
73
138
* Click on the `Edit Survey` pencil to the right of `What codebase do you want to deploy?`
0 commit comments