# Split a variable?

**URL:** <https://forum.ansible.com/t/split-a-variable/24204>\
**Category:** Ansible Project\
**Created:** [April 12, 2017, 3:48pm UTC](https://forum.ansible.com/t/split-a-variable/24204 "2017-04-12T15:48:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ouafnico](https://avatars.discourse-cdn.com/v4/letter/o/7feea3/32.png) [@ouafnico](https://forum.ansible.com/u/ouafnico)\
**Post date:** [April 12, 2017, 3:48pm UTC](https://forum.ansible.com/t/split-a-variable/24204/1 "2017-04-12T15:48:43Z")

</div>

Hi all,

I’m searching how to split a variable with ansible.  
For example on my playbook I got the variable {{install[‘myhostname’]}}.  
Actually this viarable is hostname.domain.

How can I split it to 2 variables, hostname and domain ?

Thanks !

---

<div class="post-metadata">

**Author:** ![Phonthip\_Namkaew](https://avatars.discourse-cdn.com/v4/letter/p/eada6e/32.png) [@Phonthip\_Namkaew](https://forum.ansible.com/u/Phonthip_Namkaew)\
**Post date:** [April 13, 2017, 5:36am UTC](https://forum.ansible.com/t/split-a-variable/24204/2 "2017-04-13T05:36:55Z")

</div>

[https://blog.billyc.io/2017/02/12/ansible-snippets---splitting-variables/](https://blog.billyc.io/2017/02/12/ansible-snippets---splitting-variables/)
