Ansible_roles_check_mode = true using custom Job template

Problem:

We’d like to use “ansible_roles_check_mode = true” with a custom Job template that runs a single role based on user input.

When we run the the below Job template the “ansible_roles_check_mode = true” parameter is being ignored.

Write now “ansible_roles_check_mode = true” is a global parameter but I’ve tried as hostgroup and host level too.

When using the default “Ansible Roles - Ansible Default” Job Template for all Ansible roles “ansible_roles_check_mode = true” works as expected.

Expected outcome:

Single Ansible role is ran against a remote host with “ansible_roles_check_mode = true” using custom Job template.

Foreman and Proxy versions:
3.1.1.3

Foreman and Proxy plugin versions:
foreman_ansible 7.0.4.1

Distribution and version:
Red Hat 7.9

Other relevant data:

This is our custom Job template that takes user input for the role name(s):

- hosts: all
  pre_tasks:
    - name: Display all parameters known for the Foreman host
      debug:
        var: foreman
      tags:
        - always
  vars:
    rolename: <%= input('rolename') %>

  tasks:
    - name: Apply Ansible Specific roles
      include_role:
        name: "{{ item }}"
      tags:
        - always
      with_items: "{{ rolename }}"

AFAIK you can only use the check_mode if the callback plugin is enabled.
On Foreman 3.6 (foreman_ansible 11.0.0) we added a new feature that allows you to enable the callback plugin on any Ansible job template. You are using an old version where the callback plugin is only enabled for the default “Ansible Roles - Ansible Default” Job Template.

Ok thanks very much. That explains it :slight_smile: