This is an automated email from the ASF dual-hosted git repository.
kezhenxu94 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-terraform.git
The following commit(s) were added to refs/heads/main by this push:
new cb51734 Update Ansible tasks to run as skywalking user (#21)
cb51734 is described below
commit cb517342c3e438f303ab3459003ed20239ae6b13
Author: Rahul Bajaj <[email protected]>
AuthorDate: Fri Aug 18 02:18:19 2023 -0400
Update Ansible tasks to run as skywalking user (#21)
---
README.md | 2 +-
ansible/playbooks/install-skywalking.yml | 21 ++++++++++++++-------
ansible/roles/skywalking/tasks/main.yml | 4 ++--
3 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/README.md b/README.md
index d6d9ca7..5c91f17 100644
--- a/README.md
+++ b/README.md
@@ -117,7 +117,7 @@ This guide provides steps on using Ansible to install
Apache SkyWalking on AWS i
Save the SSH key file path generated by Terraform to a variable for future use:
```
-cd ansible
+cd ../ansible/
SSH_KEY_FILE=$(terraform -chdir=../aws output -raw ssh-user-key-file)
echo $SSH_KEY_FILE
```
diff --git a/ansible/playbooks/install-skywalking.yml
b/ansible/playbooks/install-skywalking.yml
index b7e3902..2fde5ea 100644
--- a/ansible/playbooks/install-skywalking.yml
+++ b/ansible/playbooks/install-skywalking.yml
@@ -14,15 +14,22 @@
# limitations under the License.
---
-- hosts: all
+- name: Create skywalking group
+ hosts: all
+ gather_facts: false
+ tasks:
+ - group:
+ name: skywalking
+ state: present
+
+- name: Create skywalking user
+ hosts: all
gather_facts: false
tasks:
- - name: Create user skywalking
- become: true
- user:
- name: skywalking
- group: skywalking
- state: present
+ - user:
+ name: skywalking
+ group: skywalking
+ state: present
- name: Install Java
hosts: all
diff --git a/ansible/roles/skywalking/tasks/main.yml
b/ansible/roles/skywalking/tasks/main.yml
index 0d55e23..c25b823 100644
--- a/ansible/roles/skywalking/tasks/main.yml
+++ b/ansible/roles/skywalking/tasks/main.yml
@@ -49,11 +49,11 @@
oap_bundled: "{{ groups['skywalking_oap'][1:] if groups['skywalking_oap']
| length > 1 else [] }}"
- name: Run the OAPSericeInit script
- shell: /usr/local/skywalking/bin/oapServiceInit.sh
+ shell: "sudo -u skywalking /usr/local/skywalking/bin/oapServiceInit.sh"
when: inventory_hostname in oap_standalone
- name: Run the OAPSericeNoInit script
- shell: /usr/local/skywalking/bin/oapServiceNoInit.sh
+ shell: "sudo -u skywalking /usr/local/skywalking/bin/oapServiceNoInit.sh"
when: inventory_hostname in oap_bundled
- name: Generate systemd unit file for oap service