[Charlotte-pm] Is there an Ansible solution to this deployment process?
Yanick Champoux
yanick at babyl.ca
Thu Aug 26 09:14:07 PDT 2021
## Step 5 of ?: install_service.yml
Ansible by default uses the Jinja2 templating system
(pretty similar to Mustache and Handlebars). In your instructions
you have SITENAME that is a per-host variable, so I'll go back to my
inventory file and augment the host configs with it:
```
all:
hosts:
'william.charlotte.us':
ansible_ssh_host: 192.168.0.103
sitename: william
children:
onboarding:
hosts:
'yanick.ottawa.ca':
sitename: yanick
ansible_ssh_host: 192.168.0.101
ansible_ssh_user: yanick
```
I'll assume that `cv.service` is a template (that I'll rename
`cv.service.jinja2`) that might have some tweaks for the
different installs.
So let's do this:
```
# in roles/onboard/tasks/install_service.yml
- name: install service script
# become means "become the super-user"
become: yes
template:
src: ../files/cv.service.jinja2
dest: /etc/systemd/system/cv.service
mode: '644'
- name: ensure the service is running
service:
name: cv
enabled: yes
state: started
```
More to come,
`/anick`
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/charlotte-pm/attachments/20210826/9142f535/attachment-0001.html>
More information about the Charlotte-pm
mailing list