Skip to content

Your first automation

This tutorial takes about fifteen minutes. You will run a Bash job, see a failure, run an Ansible playbook from Git and join two steps into a workflow. Nothing touches real servers: Ansible targets the runner itself.

You need a running Liftway (locally is fine) and a Git repository you can push to, such as a scratch project in your GitLab.

1. Run a Bash job

  1. Open Templates → Add job template and choose Bash.
  2. Name it hello-runway and enter the script:

    echo "Hello from Liftway"
    uname -a
    
  3. Save, then press Launch.

The job page opens. The step goes pending → starting → running → successful, and Output shows both lines. Open Info to see who launched it, which executor ran it and on which runner host.

Bash runs with bash --noprofile --norc -eo pipefail: any failing command or pipeline stage fails the job.

2. See a failure on purpose

Create a second Bash template, expected-failure:

echo "About to fail"
exit 3

Launch it. The output shows About to fail and the job ends failed, because the script exited with a non-zero code. This is what a broken script looks like — useful to know before you need it.

3. Put a playbook in Git

Commit two files to your repository:

playbooks/preflight.yml
- name: Liftway preflight
  hosts: all
  gather_facts: false
  tasks:
    - name: Say hello
      ansible.builtin.debug:
        msg: "Hello from {{ inventory_hostname }}"
inventories/local.yml
all:
  hosts:
    localhost:
      ansible_connection: local
      ansible_python_interpreter: "{{ ansible_playbook_python }}"

localhost with a local connection means "the runner itself": a pod in Kubernetes, your machine with make dev.

4. Connect the repository

  1. If the repository is private, first create a credential: Credentials → Add, type Git HTTPS token (or GitLab Deploy Token), with a token that has read_repository. See Credentials.
  2. Projects → Add project: name playbooks, the HTTPS URL (https://gitlab.example.com/team/playbooks.git), branch main, and the credential.
  3. Press Sync. When it finishes, the card shows the commit, and Liftway has found playbooks/preflight.yml and inventories/local.yml.

5. Create the inventory

Inventories → Add inventory, source Project, project playbooks, path inventories/local.yml. Save, then Sync. The inventory now shows one host, localhost.

6. Create and launch the Ansible template

Templates → Add job template → Ansible:

Field Value
Name preflight
Project playbooks
Playbook playbooks/preflight.yml
Inventory local

Launch it. The output shows Ansible's task lines with ok, changed and failed highlighted. Info shows the Git revision that ran and the hosts Ansible actually touched.

7. Chain the steps into a workflow

  1. Workflows → New workflow, name first-workflow.
  2. Add a Job template step preflight.
  3. Add a Job template step hello-runway. Under Run after pick preflight with condition On success.
  4. Add a third step expected-failure, after hello-runway.
  5. Add a fourth step hello-runway again, named cleanup, after expected-failure with On failure.
  6. Save and Launch.

The run page draws the graph and colours each step as it changes:

preflight ──► hello-runway ──► expected-failure ──on failure──► cleanup

expected-failure fails, cleanup runs and succeeds — and the run is still failed. A successful handler never hides the failure. Change cleanup's condition to Always and it also runs after a success.

What you have proved

  • Liftway accepts sign-in and runs jobs
  • It tells success from failure by exit code and Ansible results
  • It can read your Git repository and pin a commit
  • Workflows wait for dependencies and run handlers on failure

Where to go next