Created
May 18, 2016 19:24
-
-
Save juliedavila/1dfa865dfdf79280b0f64e6097a5c269 to your computer and use it in GitHub Desktop.
Stateful counting mechanism
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
| --- | |
| - name: Sequential | |
| hosts: localhost | |
| connection: local | |
| vars: | |
| basename: launch_config_ | |
| tasks: | |
| - block: | |
| - include_vars: config_counter.yml | |
| - name: Set counter | |
| set_fact: | |
| count: "{{ last_num|int + 1 }}" | |
| - name: Set new name | |
| set_fact: | |
| gen_name: "{{ basename + count }}" | |
| - name: Template vars for future run | |
| template: | |
| src: config_counter.yml.j2 | |
| dest: ./config_counter.yml | |
| rescue: | |
| - name: Set first name | |
| set_fact: | |
| gen_name: "{{ basename + '1' }}" | |
| count: 1 | |
| - name: Template vars for future run | |
| template: | |
| src: config_counter.yml.j2 | |
| dest: ./config_counter.yml | |
| always: | |
| - name: Dbug | |
| debug: | |
| msg: "{{ gen_name }}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment