質問編集履歴
8
説明文の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -35,24 +35,20 @@
|
|
35
35
|
```
|
36
36
|
|
37
37
|
### 試したこと
|
38
|
+
申し訳ございません。
|
39
|
+
こちらlist配列0番目に情報が収まっており、個別に内容を取り出せないことが分かりました。
|
38
40
|
変数の型を確認
|
39
41
|
```
|
40
42
|
msg: "{{ check_image.stdout_lines | type_debug }}"
|
41
43
|
"msg": "list"
|
42
44
|
```
|
43
45
|
|
44
|
-
下記のような形でkeyを指定してもだめでした。
|
45
46
|
```
|
46
|
-
check_image.stdout_lines['AAAAA.BBBBB-CCCCC']
|
47
|
-
check_image.stdout_lines
|
47
|
+
msg: "{{ check_image.stdout_lines[0] }}"
|
48
|
+
```
|
49
|
+
上記の結果
|
50
|
+
```
|
51
|
+
"msg": " \"AAAAA.BBBBB-CCCCC\": \"hoge.co.jp:8080/hoge/image:yyyymmdd-mmssss\","
|
52
|
+
}
|
48
53
|
```
|
49
54
|
|
50
|
-
下記も試したのですがエラーになりました
|
51
|
-
```
|
52
|
-
msg: "{{ item.value }}"
|
53
|
-
with_items: "{{ check_image.stdout_lines }}"
|
54
|
-
```
|
55
|
-
エラー内容
|
56
|
-
```
|
57
|
-
fatal: [localhost]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'ansible.utils.unsafe_proxy.AnsibleUnsafeText object' has no attribute 'value'. 'ansible.utils.unsafe_proxy.AnsibleUnsafeText object' has no attribute 'value'\n\nThe error appears to be in '/check_image.yml': line ?, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n# changed_when: true\n- name: Echo\n ^ here\n"}
|
58
|
-
```
|
7
説明文の修正
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Ansible registerで取得した
|
1
|
+
Ansible registerで取得した list型の情報に対してkeyを指定して値を取得したい
|
test
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
### 実現したいこと
|
2
2
|
|
3
|
-
Unixコマンドを実行して、実行結果からAAAAAをgrepした結果をcheck_imageという変数で
|
3
|
+
Unixコマンドを実行して、実行結果からAAAAAをgrepした結果をcheck_imageという変数でlist型の情報として取得しています。
|
4
4
|
ここからkeyである AAAAA.BBBBB-CCCCC を指定して値である hoge.co.jp:8080/hoge/image:yyyymmdd-mmssss だけを取得したいです。
|
5
5
|
AAAAA.BBBBB-CCCCC の文字列にはドット(.)とハイフン(-)が含まれています。
|
6
|
-
|
6
|
+
list型の操作方法を調べているのですが、VARIABLE IS NOT DEFINEDや構文エラーとなってしまい値が取得出来ません。
|
7
7
|
やり方をご存じの方がいらっしゃいましたらご教授頂けないでしょうか。
|
8
8
|
宜しくお願い致します。
|
9
9
|
|
@@ -35,6 +35,11 @@
|
|
35
35
|
```
|
36
36
|
|
37
37
|
### 試したこと
|
38
|
+
変数の型を確認
|
39
|
+
```
|
40
|
+
msg: "{{ check_image.stdout_lines | type_debug }}"
|
41
|
+
"msg": "list"
|
42
|
+
```
|
38
43
|
|
39
44
|
下記のような形でkeyを指定してもだめでした。
|
40
45
|
```
|
6
説明文の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -42,3 +42,12 @@
|
|
42
42
|
check_image.stdout_lines.AAAAA.BBBBB-CCCCC
|
43
43
|
```
|
44
44
|
|
45
|
+
下記も試したのですがエラーになりました
|
46
|
+
```
|
47
|
+
msg: "{{ item.value }}"
|
48
|
+
with_items: "{{ check_image.stdout_lines }}"
|
49
|
+
```
|
50
|
+
エラー内容
|
51
|
+
```
|
52
|
+
fatal: [localhost]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'ansible.utils.unsafe_proxy.AnsibleUnsafeText object' has no attribute 'value'. 'ansible.utils.unsafe_proxy.AnsibleUnsafeText object' has no attribute 'value'\n\nThe error appears to be in '/check_image.yml': line ?, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n# changed_when: true\n- name: Echo\n ^ here\n"}
|
53
|
+
```
|
5
説明文の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -26,7 +26,7 @@
|
|
26
26
|
ansible.builtin.debug:
|
27
27
|
var: check_image.stdout_lines.AAAAA.BBBBB-CCCCC
|
28
28
|
```
|
29
|
-
```check_imageの中身
|
29
|
+
```check_image.stdout_linesの中身
|
30
30
|
ok: [localhost] => {
|
31
31
|
"check_image.stdout_lines": [
|
32
32
|
" \"AAAAA.BBBBB-CCCCC\": \"hoge.co.jp:8080/hoge/image:yyyymmdd-mmssss\","
|
4
説明文の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -38,7 +38,7 @@
|
|
38
38
|
|
39
39
|
下記のような形でkeyを指定してもだめでした。
|
40
40
|
```
|
41
|
-
check_image['AAAAA.BBBBB-CCCCC']
|
41
|
+
check_image.stdout_lines['AAAAA.BBBBB-CCCCC']
|
42
|
-
check_image.AAAAA.BBBBB-CCCCC
|
42
|
+
check_image.stdout_lines.AAAAA.BBBBB-CCCCC
|
43
43
|
```
|
44
44
|
|
3
説明文の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -24,11 +24,11 @@
|
|
24
24
|
register: check_image
|
25
25
|
- name: Echo
|
26
26
|
ansible.builtin.debug:
|
27
|
-
var: check_image.AAAAA.BBBBB-CCCCC
|
27
|
+
var: check_image.stdout_lines.AAAAA.BBBBB-CCCCC
|
28
28
|
```
|
29
29
|
```check_imageの中身
|
30
30
|
ok: [localhost] => {
|
31
|
-
"check_image": [
|
31
|
+
"check_image.stdout_lines": [
|
32
32
|
" \"AAAAA.BBBBB-CCCCC\": \"hoge.co.jp:8080/hoge/image:yyyymmdd-mmssss\","
|
33
33
|
]
|
34
34
|
}
|
2
説明文の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -28,7 +28,7 @@
|
|
28
28
|
```
|
29
29
|
```check_imageの中身
|
30
30
|
ok: [localhost] => {
|
31
|
-
"check_image
|
31
|
+
"check_image": [
|
32
32
|
" \"AAAAA.BBBBB-CCCCC\": \"hoge.co.jp:8080/hoge/image:yyyymmdd-mmssss\","
|
33
33
|
]
|
34
34
|
}
|
1
説明文の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -26,6 +26,13 @@
|
|
26
26
|
ansible.builtin.debug:
|
27
27
|
var: check_image.AAAAA.BBBBB-CCCCC
|
28
28
|
```
|
29
|
+
```check_imageの中身
|
30
|
+
ok: [localhost] => {
|
31
|
+
"check_image.stdout_lines": [
|
32
|
+
" \"AAAAA.BBBBB-CCCCC\": \"hoge.co.jp:8080/hoge/image:yyyymmdd-mmssss\","
|
33
|
+
]
|
34
|
+
}
|
35
|
+
```
|
29
36
|
|
30
37
|
### 試したこと
|
31
38
|
|