Skip to content
This repository was archived by the owner on Oct 8, 2025. It is now read-only.
This repository was archived by the owner on Oct 8, 2025. It is now read-only.

Fail builds if host is missing #186

@gregharvey

Description

@gregharvey

We had an issue where a missing Ansible host (due to a temporary API outage at AWS) caused ce-deploy to run but skip playbooks - which is just a warning and not a failure, so we get a zero return code from Ansible - thus the track file was incorrectly updated:

We need Ansible to fail when the host is missing to avoid this. I have tested this playbook, which will do the job:

- hosts: localhost
  connection: local
  become: false
  tasks:
    - name: Ensure the hostname check variable is empty.
      ansible.builtin.set_fact:
        _ce_deploy_ansible_host_check: ""
    - name: Check to see if the Ansible host or hostgroup exists.
      ansible.builtin.set_fact:
        _ce_deploy_ansible_host_check: "{{ item }}"
      with_inventory_hostnames:
        - "{{ _ce_deploy_ansible_host }}"
    - ansible.builtin.fail:
        msg: "Host does not exist!"
      when: _ce_deploy_ansible_host_check | length == 0

We'll have to pass this _ce_deploy_ansible_host in to a play as an extra var and knit a call to this playbook into build.sh somehow:

Executing a deploy will need to be dependent on the host check succeeding and hostname will need to be a variable like it is in ce-provision, we'll have to stop coding the hostname/group directly into the playbook for the deploy.

A bit of refactoring to do, but something like this should work nicely to stop a false-positive build caused by a host being skipped.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions