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 d3f1b21  Do not run init job for h2 storage
d3f1b21 is described below

commit d3f1b216e915e5a5470fd417dee9185bc493f85d
Author: kezhenxu94 <[email protected]>
AuthorDate: Fri Sep 1 22:05:02 2023 +0800

    Do not run init job for h2 storage
---
 README.md                                                             | 2 +-
 ansible/roles/skywalking/tasks/main.yml                               | 3 +--
 ansible/roles/skywalking/templates/skywalking-oap.service.j2          | 4 ++++
 ansible/{playbooks/install-skywalking.yml => skywalking.yml}          | 0
 .../template/skywalking.yaml.tftpl => template/inventory.yaml.tftpl}  | 0
 aws/ec2-main.tf                                                       | 2 +-
 6 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/README.md b/README.md
index 1fe6a67..a8dfc52 100644
--- a/README.md
+++ b/README.md
@@ -154,7 +154,7 @@ You should see output for each IP with a `SUCCESS` status:
 After confirming connectivity, proceed to install Apache SkyWalking using the 
Ansible playbook:
 
 ```
-ansible-playbook -u ec2-user playbooks/install-skywalking.yml -i 
inventory/skywalking.yaml
+ansible-playbook skywalking.yml
 ```
 
 ### 4. Configurations
diff --git a/ansible/roles/skywalking/tasks/main.yml 
b/ansible/roles/skywalking/tasks/main.yml
index 60f1bac..499e6cd 100644
--- a/ansible/roles/skywalking/tasks/main.yml
+++ b/ansible/roles/skywalking/tasks/main.yml
@@ -65,8 +65,7 @@
 
 - name: Check hostgroup size
   set_fact:
-    group_size: "{{ groups['skywalking_oap'] | length }}"
-    oap_init_node: "{{ [groups['skywalking_oap'][0]] }}"
+    oap_init_node: "{{ (inventory_hostname in groups['skywalking_oap'] and 
hostvars[inventory_hostname]['database']['type'] == 'h2') | ternary([], 
[groups['skywalking_oap'][0]]) }}"
 
 - name: Run the OAPSericeInit script
   command: "sudo -u skywalking -- sh -c 'set -a; source 
/home/skywalking/oap.env; set +a; /usr/local/skywalking/bin/oapServiceInit.sh'"
diff --git a/ansible/roles/skywalking/templates/skywalking-oap.service.j2 
b/ansible/roles/skywalking/templates/skywalking-oap.service.j2
index a6f6cf1..e27a5ca 100644
--- a/ansible/roles/skywalking/templates/skywalking-oap.service.j2
+++ b/ansible/roles/skywalking/templates/skywalking-oap.service.j2
@@ -22,7 +22,11 @@ Type=simple
 User=skywalking
 Group=skywalking
 EnvironmentFile=/home/skywalking/oap.env
+{% if hostvars[inventory_hostname]['database']['type'] == 'h2' %}
+ExecStart=/usr/local/skywalking/bin/oapService.sh
+{% else %}
 ExecStart=/usr/local/skywalking/bin/oapServiceNoInit.sh
+{% endif %}
 TimeoutSec=300
 KillMode=process
 ExecReload=/bin/kill -HUP $MAINPID
diff --git a/ansible/playbooks/install-skywalking.yml b/ansible/skywalking.yml
similarity index 100%
rename from ansible/playbooks/install-skywalking.yml
rename to ansible/skywalking.yml
diff --git a/ansible/inventory/template/skywalking.yaml.tftpl 
b/ansible/template/inventory.yaml.tftpl
similarity index 100%
rename from ansible/inventory/template/skywalking.yaml.tftpl
rename to ansible/template/inventory.yaml.tftpl
diff --git a/aws/ec2-main.tf b/aws/ec2-main.tf
index ce36306..6d7dab1 100644
--- a/aws/ec2-main.tf
+++ b/aws/ec2-main.tf
@@ -33,7 +33,7 @@ resource "aws_security_group" "public-egress-access" {
 resource "local_file" "inventories" {
   filename        = "${path.module}/../ansible/inventory/skywalking.yaml"
   file_permission = "0600"
-  content = 
templatefile("${path.module}/../ansible/inventory/template/skywalking.yaml.tftpl",
 {
+  content = 
templatefile("${path.module}/../ansible/template/inventory.yaml.tftpl", {
     bastion           = aws_instance.bastion[0]
     oap_instances     = aws_instance.skywalking-oap
     ui_instances      = aws_instance.skywalking-ui

Reply via email to