質問編集履歴
4
書式修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -16,9 +16,9 @@
|
|
16
16
|
|
17
17
|
> users:
|
18
18
|
|
19
|
-
|
19
|
+
'- { name: 'a', uid: 123, group: 'x' }
|
20
20
|
|
21
|
-
|
21
|
+
'- { name: 'b', uid: 124, group: 'x' }
|
22
22
|
|
23
23
|
|
24
24
|
|
3
書式変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -16,9 +16,9 @@
|
|
16
16
|
|
17
17
|
> users:
|
18
18
|
|
19
|
-
'- { name: 'a', uid: 123, group: 'x' }
|
19
|
+
<span> </span> '- { name: 'a', uid: 123, group: 'x' }
|
20
20
|
|
21
|
-
'- { name: 'b', uid: 124, group: 'x' }
|
21
|
+
<span> </span> '- { name: 'b', uid: 124, group: 'x' }
|
22
22
|
|
23
23
|
|
24
24
|
|
2
エラー内容変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,29 +2,47 @@
|
|
2
2
|
|
3
3
|
a,bをxに所属させたいのですがエラーが出ます。OSはAnsible操作端末も構築対象サーバもCentOS7です。
|
4
4
|
|
5
|
+
|
6
|
+
|
7
|
+
### /tmp/group_vars/user_groups.yml(※以降、ハイフン前の「'」は無視して下さい)
|
8
|
+
|
9
|
+
> user_groups:
|
10
|
+
|
5
|
-
|
11
|
+
'- { name: 'x', gid: 100 }
|
6
12
|
|
7
13
|
|
8
14
|
|
9
|
-
###
|
15
|
+
### /tmp/group_vars/users.yml
|
10
16
|
|
11
|
-
>
|
17
|
+
> users:
|
12
18
|
|
13
|
-
'- { name: '
|
19
|
+
'- { name: 'a', uid: 123, group: 'x' }
|
20
|
+
|
21
|
+
'- { name: 'b', uid: 124, group: 'x' }
|
14
22
|
|
15
23
|
|
16
24
|
|
17
|
-
###
|
25
|
+
### /tmp/setup.yml
|
18
26
|
|
19
|
-
>
|
27
|
+
> - hosts: 192.168.100.251
|
20
28
|
|
21
|
-
|
29
|
+
remote_user: root
|
22
30
|
|
31
|
+
become: true
|
32
|
+
|
33
|
+
roles:
|
34
|
+
|
35
|
+
'- setup
|
36
|
+
|
37
|
+
vars_files:
|
38
|
+
|
23
|
-
|
39
|
+
'- group_vars/user_groups.yml
|
40
|
+
|
41
|
+
'- group_vars/users.yml
|
24
42
|
|
25
43
|
|
26
44
|
|
27
|
-
### create_user_group.yml
|
45
|
+
### /tmp/roles/useradd/task/create_user_group.yml
|
28
46
|
|
29
47
|
> '- hosts: 192.168.100.251
|
30
48
|
|
@@ -46,7 +64,7 @@
|
|
46
64
|
|
47
65
|
with_items:
|
48
66
|
|
49
|
-
'- "{{ groups }}"
|
67
|
+
'- "{{ user_groups }}"
|
50
68
|
|
51
69
|
|
52
70
|
|
@@ -68,15 +86,15 @@
|
|
68
86
|
|
69
87
|
### 実行結果
|
70
88
|
|
71
|
-
[root@HOGE tmp]# ansible-playbook /tmp/create_user_group.yml
|
89
|
+
[root@HOGE tmp]# ansible-playbook /tmp/roles/useradd/task/create_user_group.yml
|
72
90
|
|
73
91
|
|
74
92
|
|
75
|
-
PLAY [192.168.100.251] *****************************************************************************************************************
|
93
|
+
PLAY [192.168.100.251] ****************************************************************************************************************************
|
76
94
|
|
77
95
|
|
78
96
|
|
79
|
-
TASK [Gathering Facts] *****************************************************************************************************************
|
97
|
+
TASK [Gathering Facts] ****************************************************************************************************************************
|
80
98
|
|
81
99
|
Enter passphrase for key '/root/.ssh/id_rsa':
|
82
100
|
|
@@ -84,20 +102,20 @@
|
|
84
102
|
|
85
103
|
|
86
104
|
|
87
|
-
TASK [create group] ********************************************************************************************************************
|
105
|
+
TASK [create group] *******************************************************************************************************************************
|
88
106
|
|
89
|
-
fatal: [192.168.100.251]: FAILED! => {"msg": "
|
107
|
+
fatal: [192.168.100.251]: FAILED! => {"msg": "'user_groups' is undefined"}
|
90
108
|
|
91
|
-
to retry, use: --limit @/tmp/create_user_group.retry
|
109
|
+
to retry, use: --limit @/tmp/roles/useradd/task/create_user_group.retry
|
92
110
|
|
93
111
|
|
94
112
|
|
95
|
-
PLAY RECAP *****************************************************************************************************************************
|
113
|
+
PLAY RECAP ****************************************************************************************************************************************
|
96
114
|
|
97
115
|
192.168.100.251 : ok=1 changed=0 unreachable=0 failed=1
|
98
116
|
|
99
117
|
|
100
118
|
|
101
|
-
|
119
|
+
修正致しました。
|
102
120
|
|
103
121
|
ご教示いただけますと幸いです。宜しくお願い致します。
|
1
Markdown記法挿入
test
CHANGED
File without changes
|
test
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
|
9
9
|
### addgroup.yml(※以降、行頭の「'」は実際は入っておりません)
|
10
10
|
|
11
|
-
groups:
|
11
|
+
> groups:
|
12
12
|
|
13
13
|
'- { name: 'x', gid: 100 }
|
14
14
|
|
@@ -16,7 +16,7 @@
|
|
16
16
|
|
17
17
|
### adduser.yml
|
18
18
|
|
19
|
-
users:
|
19
|
+
> users:
|
20
20
|
|
21
21
|
'- { name: 'a', uid: 123, group: 'x' }
|
22
22
|
|
@@ -26,7 +26,7 @@
|
|
26
26
|
|
27
27
|
### create_user_group.yml
|
28
28
|
|
29
|
-
'- hosts: 192.168.100.251
|
29
|
+
> '- hosts: 192.168.100.251
|
30
30
|
|
31
31
|
remote_user: root
|
32
32
|
|
@@ -50,7 +50,7 @@
|
|
50
50
|
|
51
51
|
|
52
52
|
|
53
|
-
'- name: create user
|
53
|
+
> '- name: create user
|
54
54
|
|
55
55
|
user:
|
56
56
|
|
@@ -63,6 +63,8 @@
|
|
63
63
|
with_items:
|
64
64
|
|
65
65
|
'- "{{ users }}"
|
66
|
+
|
67
|
+
|
66
68
|
|
67
69
|
### 実行結果
|
68
70
|
|