FeatureSignals

Ansible Collection

Use the FeatureSignals Ansible collection to automate feature flag management alongside your infrastructure. Define flags, segments, environments, and API keys in YAML playbooks — idempotent, auditable, and reproducible.

Installation

Install the FeatureSignals collection from Ansible Galaxy:

Install via ansible-galaxyBash
1
ansible-galaxy collection install featuresignals.featuresignals

Or declare it in your requirements.yml:

requirements.ymlYAML
1
2
3
collections:
  - name: featuresignals.featuresignals
    version: ">=1.0.0"
Install from requirementsBash
1
ansible-galaxy collection install -r requirements.yml

Authentication

All modules require an API token. Provide it via environment variable or the api_token module parameter:

auth.ymlYAML
1
2
3
4
5
6
7
8
9
10
11
12
# Option 1: Environment variable (recommended)
# export FEATURESIGNALS_API_TOKEN="fs_api_..."


# Option 2: Module parameter
- name: Create a flag
  featuresignals.featuresignals.featuresignals_flag:
    api_token: "{{ vault_featuresignals_api_token }}"
    project_key: "webapp"
    key: "dark-mode"
    name: "Dark Mode"
    type: "boolean"
    default_value: false

Playbook Examples

Provision a Complete Project

A playbook that creates a project, environments, segments, and flags in one run:

provision-flags.ymlYAML
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
---
- name: Provision FeatureSignals resources
  hosts: localhost
  gather_facts: false
  vars:
    project_key: "webapp"


  tasks:
    - name: Create staging environment
      featuresignals.featuresignals.featuresignals_environment:
        project_key: "{{ project_key }}"
        key: "staging"
        name: "Staging"
        description: "Pre-production staging environment"


    - name: Create production environment
      featuresignals.featuresignals.featuresignals_environment:
        project_key: "{{ project_key }}"
        key: "production"
        name: "Production"
        description: "Production environment"


    - name: Create beta users segment
      featuresignals.featuresignals.featuresignals_segment:
        project_key: "{{ project_key }}"
        key: "beta-users"
        name: "Beta Users"
        description: "Users enrolled in the beta program"
        rules:
          - attribute: "email"
            operator: "ends_with"
            values:
              - "@beta.featuresignals.com"
              - "@testers.featuresignals.com"


    - name: Create dark mode feature flag
      featuresignals.featuresignals.featuresignals_flag:
        project_key: "{{ project_key }}"
        key: "dark-mode"
        name: "Dark Mode"
        description: "Enable the new dark mode UI"
        type: "boolean"
        default_value: false


    - name: Create checkout v2 flag with targeting
      featuresignals.featuresignals.featuresignals_flag:
        project_key: "{{ project_key }}"
        key: "checkout-v2"
        name: "Checkout v2"
        type: "boolean"
        default_value: false
        targeting:
          rules:
            - segment_key: "beta-users"
              serve_value: true
        rollout:
          percentage: 10
          serve_value: true


    - name: Create production API key
      featuresignals.featuresignals.featuresignals_api_key:
        project_key: "{{ project_key }}"
        name: "Production SDK Key"
        type: "server"
        environment_keys:
          - "production"
      register: api_key_result


    - name: Store API key in vault
      ansible.builtin.set_fact:
        prod_sdk_key: "{{ api_key_result.token }}"
      no_log: true

Toggle Flags During Deployment

Integrate flag toggling into your deployment playbooks. Enable a maintenance mode flag before deployment, then disable it after:

deploy-with-flags.ymlYAML
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
---
- name: Deploy with feature flag coordination
  hosts: app_servers
  vars:
    project_key: "webapp"


  tasks:
    - name: Enable maintenance mode flag
      featuresignals.featuresignals.featuresignals_flag:
        project_key: "{{ project_key }}"
        key: "maintenance-mode"
        state: "enabled"
      delegate_to: localhost
      run_once: true


    - name: Deploy application
      ansible.builtin.import_role:
        name: app_deploy


    - name: Run smoke tests against new version
      ansible.builtin.uri:
        url: "https://{{ inventory_hostname }}/health"
        return_content: true
      register: health_check


    - name: Disable maintenance mode flag
      featuresignals.featuresignals.featuresignals_flag:
        project_key: "{{ project_key }}"
        key: "maintenance-mode"
        state: "disabled"
      delegate_to: localhost
      run_once: true
      when: health_check.status == 200

Conditional Logic with Flag Info

Use featuresignals_flag_info to query flag state and drive conditional playbook logic:

conditional-flag.ymlYAML
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
---
- name: Conditional deployment based on flag state
  hosts: localhost
  vars:
    project_key: "webapp"


  tasks:
    - name: Get flag state
      featuresignals.featuresignals.featuresignals_flag_info:
        project_key: "{{ project_key }}"
        key: "new-checkout"
      register: flag_info


    - name: Deploy new checkout service
      ansible.builtin.debug:
        msg: "Deploying new checkout service..."
      when: flag_info.enabled


    - name: Skip new checkout service
      ansible.builtin.debug:
        msg: "New checkout flag is disabled — skipping deployment."
      when: not flag_info.enabled

Module Reference

ModuleDescription
featuresignals_flagCreate, update, toggle, archive, and delete feature flags.
featuresignals_segmentDefine reusable targeting segments with rules.
featuresignals_environmentManage environments with key, name, and description.
featuresignals_api_keyProvision and rotate server-side and client-side API keys.
featuresignals_webhookConfigure webhook endpoints for flag change events.
featuresignals_flag_infoRetrieve flag details for use in conditional playbook logic.

Idempotency

All modules are idempotent. Running the same playbook multiple times produces the same result — existing flags are updated if changed, or left untouched if they already match the desired state. The modules return changed: false when no modifications are needed.

Learn More