cloud-init.yaml 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. # Licensed to the Apache Software Foundation (ASF) under one
  2. # or more contributor license agreements. See the NOTICE file
  3. # distributed with this work for additional information
  4. # regarding copyright ownership. The ASF licenses this file
  5. # to you under the Apache License, Version 2.0 (the
  6. # "License"); you may not use this file except in compliance
  7. # with the License. You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing,
  12. # software distributed under the License is distributed on an
  13. # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  14. # KIND, either express or implied. See the License for the
  15. # specific language governing permissions and limitations
  16. # under the License.
  17. #cloud-config
  18. groups:
  19. - ds
  20. users:
  21. - name: ds
  22. shell: /bin/bash
  23. primary_group: ds
  24. sudo: ALL=(ALL) NOPASSWD:ALL
  25. ssh_authorized_keys:
  26. - ${ssh_public_key}
  27. - name: root
  28. ssh_authorized_keys:
  29. - ${ssh_public_key}
  30. write_files:
  31. - path: /etc/systemd/system/dolphinscheduler-schema.service
  32. content: |
  33. [Unit]
  34. Description=DolphinScheduler service to init database schema
  35. [Service]
  36. Type=oneshot
  37. RemainAfterExit=yes
  38. Environment="DATABASE=postgresql"
  39. Environment="SPRING_PROFILES_ACTIVE=postgresql"
  40. Environment="SPRING_DATASOURCE_URL=jdbc:postgresql://${database_address}:${database_port}/${database_name}"
  41. Environment="SPRING_DATASOURCE_USERNAME=${database_username}"
  42. Environment="SPRING_DATASOURCE_PASSWORD=${database_password}"
  43. User=ds
  44. WorkingDirectory=/opt/dolphinscheduler
  45. ExecStart=bash -l /opt/dolphinscheduler/tools/bin/upgrade-schema.sh
  46. [Install]
  47. WantedBy=multi-user.target
  48. - path: /etc/systemd/system/dolphinscheduler.service
  49. content: |
  50. [Unit]
  51. Description=DolphinScheduler Service ${dolphinscheduler_component}
  52. Requires=dolphinscheduler-schema.service
  53. [Service]
  54. Environment="DATABASE=postgresql"
  55. Environment="SPRING_PROFILES_ACTIVE=postgresql"
  56. Environment="SPRING_DATASOURCE_URL=jdbc:postgresql://${database_address}:${database_port}/${database_name}"
  57. Environment="SPRING_DATASOURCE_USERNAME=${database_username}"
  58. Environment="SPRING_DATASOURCE_PASSWORD=${database_password}"
  59. Environment="REGISTRY_ZOOKEEPER_CONNECT_STRING=${zookeeper_connect_string}"
  60. Environment="WORKER_ALERT_LISTEN_HOST=${alert_server_host}"
  61. User=ds
  62. WorkingDirectory=/opt/dolphinscheduler
  63. ExecStart=bash -l /opt/dolphinscheduler/${dolphinscheduler_component}/bin/start.sh
  64. Restart=always
  65. [Install]
  66. WantedBy=multi-user.target
  67. packages: []
  68. runcmd:
  69. - chown -R ds:ds /opt/dolphinscheduler
  70. - find /opt/dolphinscheduler/ -name "start.sh" | xargs -I{} chmod +x {}
  71. - find /opt/dolphinscheduler/ -name "common.properties" | xargs -I{} sed -ie "s/^resource.storage.type=.*/resource.storage.type=S3/g" {}
  72. - find /opt/dolphinscheduler/ -name "common.properties" | xargs -I{} sed -ie "s/^resource.aws.access.key.id=.*/resource.aws.access.key.id=${s3_access_key_id}/g" {}
  73. - find /opt/dolphinscheduler/ -name "common.properties" | xargs -I{} sed -ie "s:^resource.aws.secret.access.key=.*:resource.aws.secret.access.key=${s3_secret_access_key}:g" {}
  74. - find /opt/dolphinscheduler/ -name "common.properties" | xargs -I{} sed -ie "s/^resource.aws.region=.*/resource.aws.region=${s3_region}/g" {}
  75. - find /opt/dolphinscheduler/ -name "common.properties" | xargs -I{} sed -ie "s/^resource.aws.s3.bucket.name=.*/resource.aws.s3.bucket.name=${s3_bucket_name}/g" {}
  76. - find /opt/dolphinscheduler/ -name "common.properties" | xargs -I{} sed -ie "s/^resource.aws.s3.endpoint=.*/resource.aws.s3.endpoint=${s3_endpoint}/g" {}
  77. - systemctl enable dolphinscheduler
  78. - systemctl start dolphinscheduler-schema
  79. - systemctl start dolphinscheduler