Created
February 18, 2018 21:44
-
-
Save VireshDoshi/ddc79690626043cf0def7d38f4d6ebbd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[vdo023@localhost modify_list]$ ansible-playbook -i "localhost," ./modify_list-playbook.yml | |
PLAY [localhost] ********************************************************************************************************************************** | |
TASK [modify the list values by appending to the end with _changed] ******************************************************************************* | |
ok: [localhost] => { | |
"msg": "before value: [u'listitem_1', u'listitem_2'] after value: [u'listitem_1_changed', u'listitem_2_changed']" | |
} | |
TASK [modify the list values by appending to the end with .changed] ******************************************************************************* | |
ok: [localhost] => { | |
"msg": "before value: [u'listitem_1', u'listitem_2'] after value: [u'listitem_1.changed', u'listitem_2.changed']" | |
} | |
TASK [modify the database value by adding _stg to the first word upto the first dot] ************************************************************** | |
ok: [localhost] => { | |
"msg": "before value: test.server.net after value: test_stg" | |
} | |
TASK [replace the server address dot values with forward slashes] ********************************************************************************* | |
ok: [localhost] => { | |
"msg": "before value: com.test.application:great:1.0:tar after value: com/test/application/great" | |
} | |
PLAY RECAP **************************************************************************************************************************************** | |
localhost : ok=4 changed=0 unreachable=0 failed=0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: localhost | |
connection: local | |
gather_facts: False | |
vars: | |
my_list: | |
- listitem_1 | |
- listitem_2 | |
my_database: test.server.net | |
my_manifest: "com.test.application:great:1.0:tar" | |
tasks: | |
- name: modify the list values by appending to the end with _changed | |
debug: | |
msg: "before value: {{ my_list }} after value: {{ my_list | map('regex_replace', '(.*)', '\\1_changed') | list }}" | |
- name: modify the list values by appending to the end with .changed | |
debug: | |
msg: "before value: {{ my_list }} after value: {{ my_list | map('regex_replace', '^(.*)$', '\\1.changed') | list }}" | |
- name: modify the database value by adding _stg to the first word upto the first dot | |
debug: | |
msg: "before value: {{ my_database }} after value: {{ my_database | regex_replace('([^\\.]*)\\.(.+)$', '\\1') }}_stg" | |
- name: replace the server address dot values with forward slashes | |
debug: | |
msg: "before value: {{ my_manifest }} after value: {{ my_manifest.split(':')[0] | regex_replace('[.]','/') }}/{{ my_manifest.split(':')[1] }}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment