質問編集履歴

1

修正

2021/03/31 09:05

投稿

pay_561
pay_561

スコア26

test CHANGED
File without changes
test CHANGED
@@ -8,11 +8,17 @@
8
8
 
9
9
  ```
10
10
 
11
- 上記のように現在sudoコマンドを直接利用するのは、現在非推奨になっているようなのです
11
+ 上記のように現在sudoコマンドを直接利用するのは、現在非推奨になっているようです
12
12
 
13
- どのように変更加えればよろしいでしょうか
13
+ ですがsudoモジュール使用る箇所がなく唯一使用しているのがCheck if version is installed rubyのshellモジュール
14
14
 
15
+ shellモジュール内でsudoを書かない記述方法がありますでしょうか
15
16
 
17
+ ```ここに言語を入力
18
+
19
+ shell: "sudo -iu {{ rbenv_user }} rbenv versions | grep {{ rbenv_ruby_version }}"
20
+
21
+ ```
16
22
 
17
23
 
18
24
 
@@ -28,21 +34,9 @@
28
34
 
29
35
  [WARNING]: Consider using 'become', 'become_method', and 'become_user' rather than running sudo
30
36
 
31
- fatal: [☓☓.☓☓.☓☓.☓☓]: FAILED! => {"changed": false, "cmd": "sudo -iu ec2-user rbenv versions | grep 2.7.2", "delta": "0:00:00.144188", "end": "2021-03-30 04:45:25.849273", "msg": "non-zero return code", "rc": 1, "start": "2021-03-30 04:45:25.705085", "stderr": "Warning: no Ruby detected on the system", "stderr_lines": ["Warning: no Ruby detected on the system"], "stdout": "", "stdout_lines": []}
37
+ fatal: [☓☓.☓☓.☓☓.☓☓]: FAILED! => {"changed": false, "cmd": "sudo -iu ec2-user rbenv versions | grep 2.7.2", "delta": "0:00:00.145138", "end": "2021-03-31 08:50:00.875045", "msg": "non-zero return code", "rc": 1, "start": "2021-03-31 08:50:00.729907", "stderr": "Warning: no Ruby detected on the system", "stderr_lines": ["Warning: no Ruby detected on the system"], "stdout": "", "stdout_lines": []}
32
38
 
33
39
  ...ignoring
34
-
35
-
36
-
37
- TASK [Install ruby] ***********************************************************************************************************
38
-
39
- fatal: [☓☓.☓☓.☓☓.☓☓]: FAILED! => {"msg": "The conditional check 'rbenv_check_install|failed' failed. The error was: template error while templating string: no filter named 'failed'. String: {% if rbenv_check_install|failed %} True {% else %} False {% endif %}\n\nThe error appears to be in '/var/lib/jenkins/workspace/execute_ansible/roles/ruby/tasks/main.yml': line 49, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Install ruby\n ^ here\n"}
40
-
41
-
42
-
43
- PLAY RECAP ********************************************************************************************************************
44
-
45
- ☓☓.☓☓.☓☓.☓☓ : ok=9 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=1
46
40
 
47
41
  ```
48
42
 
@@ -52,15 +46,29 @@
52
46
 
53
47
  ```ここに言語を入力
54
48
 
55
- ---
49
+ - name: 'Install packages'
56
50
 
57
- - name: Install dependencies for rbenv
51
+ yum:
58
52
 
59
- yum: name={{ item }} state=latest
53
+ name: "{{ item }}"
60
54
 
61
55
  with_items:
62
56
 
63
- - git
57
+ - gcc
58
+
59
+ - openssl-devel
60
+
61
+ - libyaml-devel
62
+
63
+ - readline-devel
64
+
65
+ - zlib-devel
66
+
67
+ - libffi-devel
68
+
69
+ - gdbm-devel
70
+
71
+ - ncurses-devel
64
72
 
65
73
 
66
74
 
@@ -102,30 +110,6 @@
102
110
 
103
111
 
104
112
 
105
- - name: Install dependencies for ruby-build (see. https://github.com/sstephenson/ruby-build/wiki)
106
-
107
- yum: name={{ item }} state=latest
108
-
109
- with_items:
110
-
111
- - gcc
112
-
113
- - openssl-devel
114
-
115
- - libyaml-devel
116
-
117
- - libffi-devel
118
-
119
- - readline-devel
120
-
121
- - zlib-devel
122
-
123
- - gdbm-devel
124
-
125
- - ncurses-devel
126
-
127
-
128
-
129
113
  - name: Install ruby-build as rbenv plugin
130
114
 
131
115
  become: yes
@@ -136,10 +120,18 @@
136
120
 
137
121
 
138
122
 
123
+ -----------ここまでインストールされていることを確認-----------------------
124
+
125
+
126
+
139
127
  - name: Check if version is installed ruby
140
128
 
141
129
  shell: "sudo -iu {{ rbenv_user }} rbenv versions | grep {{ rbenv_ruby_version }}"
142
130
 
143
131
  register: rbenv_check_install
144
132
 
133
+ changed_when: False
134
+
135
+ ignore_errors: yes
136
+
145
137
  ```