# a new variable in vars ansible\_init

**URL:** <https://forum.ansible.com/t/a-new-variable-in-vars-ansible-init/19042>\
**Category:** Ansible Developer\
**Created:** [August 18, 2015, 11:29am UTC](https://forum.ansible.com/t/a-new-variable-in-vars-ansible-init/19042 "2015-08-18T11:29:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![user72](https://avatars.discourse-cdn.com/v4/letter/u/bbce88/32.png) [@user72](https://forum.ansible.com/u/user72)\
**Post date:** [August 18, 2015, 11:29am UTC](https://forum.ansible.com/t/a-new-variable-in-vars-ansible-init/19042/1 "2015-08-18T11:29:56Z")

</div>

add a variable that takes the value of the initialization

[http://docs.ansible.com/ansible/playbooks\_variables.html](http://docs.ansible.com/ansible/playbooks_variables.html)

“ansible\_init”: “systemd”,  
“ansible\_init”: “SysV”,

“ansible\_init”: “OpenRC”,

or

“ansible\_init”: {  
“systemd”: true,

“SysV”: true,

“OpenRC”: false  
}

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [August 18, 2015, 5:30pm UTC](https://forum.ansible.com/t/a-new-variable-in-vars-ansible-init/19042/2 "2015-08-18T17:30:22Z")

</div>

I was going with: ansible\_service\_mgr

---

<div class="post-metadata">

**Author:** ![user72](https://avatars.discourse-cdn.com/v4/letter/u/bbce88/32.png) [@user72](https://forum.ansible.com/u/user72)\
**Post date:** [August 19, 2015, 6:29am UTC](https://forum.ansible.com/t/a-new-variable-in-vars-ansible-init/19042/3 "2015-08-19T06:29:23Z")

</div>

1. I took the test for the devel branch  
[https://github.com/ansible/ansible/blob/devel/lib/ansible/plugins/action/service.py](https://github.com/ansible/ansible/blob/devel/lib/ansible/plugins/action/service.py)  
after  
ansible hostname -m setup  
this variable is not present  
Are there any conditions to create a variable?

2. Partly I needed to branch the code in the playbook.

---

<div class="post-metadata">

**Author:** ![user72](https://avatars.discourse-cdn.com/v4/letter/u/bbce88/32.png) [@user72](https://forum.ansible.com/u/user72)\
**Post date:** [August 19, 2015, 6:32am UTC](https://forum.ansible.com/t/a-new-variable-in-vars-ansible-init/19042/4 "2015-08-19T06:32:43Z")

</div>

> 1. Partly I needed to branch the code in the playbook.

```auto
- name: check systemd
  shell: "cat /proc/1/comm"
  ignore_errors: yes
  register: ansible_init

- include: 'systemd_setup.yml'
  when: ansible_init.stdout.find('systemd') != -1

```

---

<div class="post-metadata">

**Author:** ![user72](https://avatars.discourse-cdn.com/v4/letter/u/bbce88/32.png) [@user72](https://forum.ansible.com/u/user72)\
**Post date:** [August 20, 2015, 7:39am UTC](https://forum.ansible.com/t/a-new-variable-in-vars-ansible-init/19042/5 "2015-08-20T07:39:03Z")

</div>

Your module does not do what I need.  
I need a variable to the current system initialization.
