Getting started with Ansible playbooks and JetPorch
JetPorch is a tool capable of interpreting simple Ansible playbooks.
It can thus be used to install packages, configure, start or stop services as well as execute commands on the gateway.
It is available by default on our gateways. For more information, please refer to https://deepwiki.com/jetporch/jetporch_docs.
How to
Create a playbook
- Start by copying a playbook sample from the wiki. Make sure that the format is Unix compliant.
On Windows, when copy/pasting to a text editor, make sure End Of File (EOF) is configured as Unix-style (LF), or convert it to unix after having created the file on the gateway.
- Create a 'yml' file in the gateway
vi myPlaybook.yml - Type 'i' to enter edition and paste
- Press Escape and type
:wq+Enter to save the file
Your playbook is now ready for execution.
Execute a playbook
# Standard usage:
jetp myPlaybook.yml
Playbook examples
Install packages
An APT module can be installed thanks to a playbook:
- name: Install the Basic Station package
groups:
- all
tasks:
- !apt
package: basicstation
Enable and start a service
sd_service module can be used directly in a playbook:
- name: Enable and Start the Basic Station service
groups:
- all
tasks:
- !sd_service
service: basicstation
enabled: true
restart: true
Edit network configuration
kconf module is a Kerlink specific module which standardizes ways to configure network settings.
This example shows how to configure a SIM card with websfr as default APN and 1234 as PIN code:
- name: Configure network
groups:
- all
tasks:
- !external
use: kconf
params:
ofono:
default_pin: "1234"
default_context:
apn: websfr
See more examples of network configuration in the dedicated page.
Using several plays in a playbook
In the previous examples, a single 'play' with single 'task' was used at a time.
As explained in JetPorch documentation, it is possible to concatenate several plays in a single playbook.
Here is an example which installs a package with APT, and configures the service with a playbook made of two plays:
- name: Install the Basic Station package
groups:
- all
tasks:
- !apt
package: basicstation
- name: Enable and start the Basic Station service
groups:
- all
tasks:
- !sd_service
service: basicstation
enabled: true
restart: true