[ansible]; working with multiple dictionary
I'm trying to run the following ::
Press to see code
- name: Snapshot BI nodes
hosts: [CLUSTER-BI,CLUSTER-BI-REPLACE]
vars_files:
- snapshot_vars.yml
user: root
any_errors_fatal: true
tasks:
- name: step 1
shell: "{{item.value}} &> {{snapshot_dir}}/ETL/{{item.key}}.log"
with_dict: "{{ ETL }}"
- name: step 2
shell: "{{item.value}} &> {{snapshot_dir}}/MSTR/{{item.key}}.log"
with_dict: "{{ MSTR }}"
getting error after step 1
How do I set a new dic for each step
python centos ansible ansible-2.x ansible-inventory
|
show 1 more comment
I'm trying to run the following ::
Press to see code
- name: Snapshot BI nodes
hosts: [CLUSTER-BI,CLUSTER-BI-REPLACE]
vars_files:
- snapshot_vars.yml
user: root
any_errors_fatal: true
tasks:
- name: step 1
shell: "{{item.value}} &> {{snapshot_dir}}/ETL/{{item.key}}.log"
with_dict: "{{ ETL }}"
- name: step 2
shell: "{{item.value}} &> {{snapshot_dir}}/MSTR/{{item.key}}.log"
with_dict: "{{ MSTR }}"
getting error after step 1
How do I set a new dic for each step
python centos ansible ansible-2.x ansible-inventory
Please show the error.
– Rob Bricheno
Nov 12 '18 at 16:58
There is no error it is just not proceeding to step 2. and if I inverse between them it will do step 2 and not 1.
– Amir Kourdi
Nov 12 '18 at 17:03
Just a guess, is this related to the use of the ampersand&
? What happens if you remove those&
characters and try running it? I realise you may want this behaviour, but lets see if the whole thing runs without them first, then work out how to deliver the behaviour you want.
– Rob Bricheno
Nov 12 '18 at 17:09
I tried to remove it, it does not work.
– Amir Kourdi
Nov 12 '18 at 17:56
please add the vars ETL and MSTR
– chenchuk
Nov 12 '18 at 18:06
|
show 1 more comment
I'm trying to run the following ::
Press to see code
- name: Snapshot BI nodes
hosts: [CLUSTER-BI,CLUSTER-BI-REPLACE]
vars_files:
- snapshot_vars.yml
user: root
any_errors_fatal: true
tasks:
- name: step 1
shell: "{{item.value}} &> {{snapshot_dir}}/ETL/{{item.key}}.log"
with_dict: "{{ ETL }}"
- name: step 2
shell: "{{item.value}} &> {{snapshot_dir}}/MSTR/{{item.key}}.log"
with_dict: "{{ MSTR }}"
getting error after step 1
How do I set a new dic for each step
python centos ansible ansible-2.x ansible-inventory
I'm trying to run the following ::
Press to see code
- name: Snapshot BI nodes
hosts: [CLUSTER-BI,CLUSTER-BI-REPLACE]
vars_files:
- snapshot_vars.yml
user: root
any_errors_fatal: true
tasks:
- name: step 1
shell: "{{item.value}} &> {{snapshot_dir}}/ETL/{{item.key}}.log"
with_dict: "{{ ETL }}"
- name: step 2
shell: "{{item.value}} &> {{snapshot_dir}}/MSTR/{{item.key}}.log"
with_dict: "{{ MSTR }}"
getting error after step 1
How do I set a new dic for each step
python centos ansible ansible-2.x ansible-inventory
python centos ansible ansible-2.x ansible-inventory
edited Nov 12 '18 at 17:01
asked Nov 12 '18 at 16:47
Amir Kourdi
63
63
Please show the error.
– Rob Bricheno
Nov 12 '18 at 16:58
There is no error it is just not proceeding to step 2. and if I inverse between them it will do step 2 and not 1.
– Amir Kourdi
Nov 12 '18 at 17:03
Just a guess, is this related to the use of the ampersand&
? What happens if you remove those&
characters and try running it? I realise you may want this behaviour, but lets see if the whole thing runs without them first, then work out how to deliver the behaviour you want.
– Rob Bricheno
Nov 12 '18 at 17:09
I tried to remove it, it does not work.
– Amir Kourdi
Nov 12 '18 at 17:56
please add the vars ETL and MSTR
– chenchuk
Nov 12 '18 at 18:06
|
show 1 more comment
Please show the error.
– Rob Bricheno
Nov 12 '18 at 16:58
There is no error it is just not proceeding to step 2. and if I inverse between them it will do step 2 and not 1.
– Amir Kourdi
Nov 12 '18 at 17:03
Just a guess, is this related to the use of the ampersand&
? What happens if you remove those&
characters and try running it? I realise you may want this behaviour, but lets see if the whole thing runs without them first, then work out how to deliver the behaviour you want.
– Rob Bricheno
Nov 12 '18 at 17:09
I tried to remove it, it does not work.
– Amir Kourdi
Nov 12 '18 at 17:56
please add the vars ETL and MSTR
– chenchuk
Nov 12 '18 at 18:06
Please show the error.
– Rob Bricheno
Nov 12 '18 at 16:58
Please show the error.
– Rob Bricheno
Nov 12 '18 at 16:58
There is no error it is just not proceeding to step 2. and if I inverse between them it will do step 2 and not 1.
– Amir Kourdi
Nov 12 '18 at 17:03
There is no error it is just not proceeding to step 2. and if I inverse between them it will do step 2 and not 1.
– Amir Kourdi
Nov 12 '18 at 17:03
Just a guess, is this related to the use of the ampersand
&
? What happens if you remove those &
characters and try running it? I realise you may want this behaviour, but lets see if the whole thing runs without them first, then work out how to deliver the behaviour you want.– Rob Bricheno
Nov 12 '18 at 17:09
Just a guess, is this related to the use of the ampersand
&
? What happens if you remove those &
characters and try running it? I realise you may want this behaviour, but lets see if the whole thing runs without them first, then work out how to deliver the behaviour you want.– Rob Bricheno
Nov 12 '18 at 17:09
I tried to remove it, it does not work.
– Amir Kourdi
Nov 12 '18 at 17:56
I tried to remove it, it does not work.
– Amir Kourdi
Nov 12 '18 at 17:56
please add the vars ETL and MSTR
– chenchuk
Nov 12 '18 at 18:06
please add the vars ETL and MSTR
– chenchuk
Nov 12 '18 at 18:06
|
show 1 more comment
1 Answer
1
active
oldest
votes
This works without the & :
---
- name: test
hosts: localhost
vars:
ETL:
file1: "echo hello etl"
file2: "echo hello2 etl"
MSTR:
file3: "echo hello3 mstr"
file4: "echo hello4 mstr"
tasks:
- name: step 1
shell: "{{item.value}} > /tmp/ETL/{{item.key}}.log"
with_dict: "{{ ETL }}"
- name: step 2
shell: "{{item.value}} > /tmp/MSTR/{{item.key}}.log"
with_dict: "{{ MSTR }}"
I end up with 4 files ( the ETL/MSTR folders must exists )
/tmp/ tree
.
├── ETL
│ ├── file1.log
│ └── file2.log
├── MSTR
│ ├── file3.log
│ └── file4.log
Thank you! It is working now
– Amir Kourdi
Nov 15 '18 at 9:47
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53266618%2fansible-working-with-multiple-dictionary%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
This works without the & :
---
- name: test
hosts: localhost
vars:
ETL:
file1: "echo hello etl"
file2: "echo hello2 etl"
MSTR:
file3: "echo hello3 mstr"
file4: "echo hello4 mstr"
tasks:
- name: step 1
shell: "{{item.value}} > /tmp/ETL/{{item.key}}.log"
with_dict: "{{ ETL }}"
- name: step 2
shell: "{{item.value}} > /tmp/MSTR/{{item.key}}.log"
with_dict: "{{ MSTR }}"
I end up with 4 files ( the ETL/MSTR folders must exists )
/tmp/ tree
.
├── ETL
│ ├── file1.log
│ └── file2.log
├── MSTR
│ ├── file3.log
│ └── file4.log
Thank you! It is working now
– Amir Kourdi
Nov 15 '18 at 9:47
add a comment |
This works without the & :
---
- name: test
hosts: localhost
vars:
ETL:
file1: "echo hello etl"
file2: "echo hello2 etl"
MSTR:
file3: "echo hello3 mstr"
file4: "echo hello4 mstr"
tasks:
- name: step 1
shell: "{{item.value}} > /tmp/ETL/{{item.key}}.log"
with_dict: "{{ ETL }}"
- name: step 2
shell: "{{item.value}} > /tmp/MSTR/{{item.key}}.log"
with_dict: "{{ MSTR }}"
I end up with 4 files ( the ETL/MSTR folders must exists )
/tmp/ tree
.
├── ETL
│ ├── file1.log
│ └── file2.log
├── MSTR
│ ├── file3.log
│ └── file4.log
Thank you! It is working now
– Amir Kourdi
Nov 15 '18 at 9:47
add a comment |
This works without the & :
---
- name: test
hosts: localhost
vars:
ETL:
file1: "echo hello etl"
file2: "echo hello2 etl"
MSTR:
file3: "echo hello3 mstr"
file4: "echo hello4 mstr"
tasks:
- name: step 1
shell: "{{item.value}} > /tmp/ETL/{{item.key}}.log"
with_dict: "{{ ETL }}"
- name: step 2
shell: "{{item.value}} > /tmp/MSTR/{{item.key}}.log"
with_dict: "{{ MSTR }}"
I end up with 4 files ( the ETL/MSTR folders must exists )
/tmp/ tree
.
├── ETL
│ ├── file1.log
│ └── file2.log
├── MSTR
│ ├── file3.log
│ └── file4.log
This works without the & :
---
- name: test
hosts: localhost
vars:
ETL:
file1: "echo hello etl"
file2: "echo hello2 etl"
MSTR:
file3: "echo hello3 mstr"
file4: "echo hello4 mstr"
tasks:
- name: step 1
shell: "{{item.value}} > /tmp/ETL/{{item.key}}.log"
with_dict: "{{ ETL }}"
- name: step 2
shell: "{{item.value}} > /tmp/MSTR/{{item.key}}.log"
with_dict: "{{ MSTR }}"
I end up with 4 files ( the ETL/MSTR folders must exists )
/tmp/ tree
.
├── ETL
│ ├── file1.log
│ └── file2.log
├── MSTR
│ ├── file3.log
│ └── file4.log
answered Nov 12 '18 at 18:19
chenchuk
1,96731322
1,96731322
Thank you! It is working now
– Amir Kourdi
Nov 15 '18 at 9:47
add a comment |
Thank you! It is working now
– Amir Kourdi
Nov 15 '18 at 9:47
Thank you! It is working now
– Amir Kourdi
Nov 15 '18 at 9:47
Thank you! It is working now
– Amir Kourdi
Nov 15 '18 at 9:47
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53266618%2fansible-working-with-multiple-dictionary%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Please show the error.
– Rob Bricheno
Nov 12 '18 at 16:58
There is no error it is just not proceeding to step 2. and if I inverse between them it will do step 2 and not 1.
– Amir Kourdi
Nov 12 '18 at 17:03
Just a guess, is this related to the use of the ampersand
&
? What happens if you remove those&
characters and try running it? I realise you may want this behaviour, but lets see if the whole thing runs without them first, then work out how to deliver the behaviour you want.– Rob Bricheno
Nov 12 '18 at 17:09
I tried to remove it, it does not work.
– Amir Kourdi
Nov 12 '18 at 17:56
please add the vars ETL and MSTR
– chenchuk
Nov 12 '18 at 18:06