---
# Update proxy env vars in StackStorm service config files
- name: proxy | Configure StackStorm services
  become: yes
  lineinfile:
    dest: /etc/{{ 'default' if ansible_facts.pkg_mgr == 'apt' else 'sysconfig' }}/{{ item.0 }}
    create: yes
    regexp: '^{{ item.1 }}='
    line: "{{ item.1 }}={{ ansible_facts.env.get(item.1) }}"
    # NB: Empty ENV var cast to 'None' string in Ansible
    state: "{{ 'present' if ansible_facts.env.get(item.1, 'None') != 'None' else 'absent' }}"
  vars:
    _services: [st2api, st2actionrunner, st2chatops]
    _proxy_vars: [http_proxy, https_proxy, no_proxy]
  loop: '{{ _services|product(_proxy_vars)|list }}'
  notify:
    - restart st2actionrunner
    - restart st2api

---
# Update proxy env vars in StackStorm service config files
- name: proxy | Configure StackStorm services
  become: yes
  lineinfile:
    dest: /etc/{{ 'default' if ansible_facts.pkg_mgr == 'apt' else 'sysconfig' }}/{{ item.0 }}
    create: yes
    regexp: '^{{ item.1 }}='
    line: "{{ item.1 }}={{ ansible_facts.env.get(item.1) }}"
    # NB: Empty ENV var cast to 'None' string in Ansible
    state: "{{ 'present' if ansible_facts.env.get(item.1, 'None') != 'None' else 'absent' }}"
  vars:
    _services: [st2api, st2actionrunner]
    _proxy_vars: [http_proxy, https_proxy, no_proxy]
  loop: '{{ _services|product(_proxy_vars)|list }}'
  notify:
    - restart st2actionrunner
    - restart st2api

Revert "st2chatops also may need proxies"
Revert "st2chatops also may need proxies"
