-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve services #828
Labels
enhancement
New feature or request
Milestone
Comments
The following procedure works for influxdb service.
log(chalk.green("Start new InfluxDB server docker container"));
await $$`docker run -d -p ${influxdbConfig.port}:8086 \
--name influxdb \
--restart always \
-v ${influxdbConfig.datapath}/data:/var/lib/influxdb2 \
-v ${influxdbConfig.datapath}/config:/etc/influxdb2 \
-v /<dirpath>/certs/fullchain.pem:/etc/ssl/fullchain.pem \
-v /<dirpath>/certs/privkey.pem:/etc/ssl/privkey.pem \
-e INFLUXD_TLS_CERT=/etc/ssl/fullchain.pem \
-e INFLUXD_TLS_KEY=/etc/ssl/privkey.pem \
-e DOCKER_INFLUXDB_INIT_MODE=setup \
-e DOCKER_INFLUXDB_INIT_USERNAME=${influxdbConfig.username} \
-e DOCKER_INFLUXDB_INIT_PASSWORD=${influxdbConfig.password} \
-e DOCKER_INFLUXDB_INIT_ORG=dtaas \
-e DOCKER_INFLUXDB_INIT_BUCKET=dtaas \
influxdb:2.7`;
log(chalk.green("InfluxDB server docker container started successfully")); Ref: stackoverflow |
Add automation scripts. rabbitmqcredentials format: credentials.csv python script: rabbitmq.py #!/bin/python3
import csv
from pprint import pprint
import subprocess
def execute_shell_command(command: str):
# Execute the command
result = subprocess.run(command, shell=True, capture_output=True, text=True)
print("Output:", result.stdout)
print("Error:", result.stderr)
def read_credentials(filename: str) -> dict:
with open(filename, mode='r', newline='') as credsFile:
credsDict = {}
credentials = csv.DictReader(credsFile, delimiter=',')
for credential in credentials:
credsDict[credential['username']] = credential['password']
vhost = credential['username']
execute_shell_command(['rabbitmqctl add_user'+ ' '
+ credential['username'] + ' ' + credential['password']])
execute_shell_command(['rabbitmqctl add_vhost ' + vhost])
execute_shell_command(['rabbitmqctl set_permissions -p'
+ ' ' + vhost + ' ' + credential['username'] + ' '
+ '".*" ".*" ".*"'])
return credsDict
if __name__ == "__main__":
credentials = read_credentials("credentials.csv")
#pprint(credentials) CAVEAT: This code is in heavy need of refactoring. docker commands# on host machine
docker cp influxdb.py influxdb:/influxdb.py
docker cp credentials.csv influxdb:/credentials.csv
docker exec -it influxdb bash
# inside docker container
python3 influxdb.py |
influxdb#!/bin/python3
import csv
import json
from pprint import pprint
import subprocess
def execute_shell_command(command: str, verbose:bool = True) -> str:
# Execute the command
result = subprocess.run(command, shell=True, capture_output=True, text=True)
if(verbose):
print("Output:", result.stdout)
if result.returncode != 0:
print("Error:", result.stderr)
return None
else:
return result.stdout
def read_credentials(filename: str) -> dict:
with open(filename, mode='r', newline='') as credsFile:
credsDict = {}
credentials = csv.DictReader(credsFile, delimiter=',')
for credential in credentials:
username = credential['username']
password = credential['password']
credsDict[username] = password
execute_shell_command(['influx user create --skip-verify -n' + ' ' + username + ' ' + '-p' + ' ' + password])
users_json_list = json.loads(execute_shell_command(['influx user list --skip-verify --json'], verbose=False))
users_json = { user_json['name']: user_json['id'] for user_json in users_json_list}
print(users_json)
for name,id in users_json.items():
execute_shell_command(['influx org create --skip-verify --name' + ' ' + name + ' ' + '--description' + ' ' + name])
print(name)
print(id)
execute_shell_command(['influx org members add --skip-verify --name' + ' ' + name + ' ' + '--owner --m' + ' ' + id])
return credsDict
if __name__ == "__main__":
credentials = read_credentials("credentials.csv")
#pprint(credentials) The format of credentials.csv is same as the one used by rabbitmq.py script. CAVEAT: This code is in heavy need of refactoring. docker commands# on host machine
docker cp influxdb.py influxdb:/influxdb.py
docker cp credentials.csv influxdb:/credentials.csv
docker exec -it influxdb bash
# inside docker container
python3 influxdb.py |
Changes to log(chalk.green("Start new InfluxDB server docker container"));
await $$`docker run -d -p ${influxdbConfig.port}:8086 \
--name influxdb \
--restart always \
-v ${influxdbConfig.datapath}/data:/var/lib/influxdb2 \
-v ${influxdbConfig.datapath}/config:/etc/influxdb2 \
-v ${influxdbConfig.datapath}/certs/fullchain.pem:/etc/ssl/fullchain.pem \
-v ${influxdbConfig.datapath}/certs/privkey.pem:/etc/ssl/privkey.pem \
-e DOCKER_INFLUXDB_INIT_MODE=setup \
-e DOCKER_INFLUXDB_INIT_USERNAME=${influxdbConfig.username} \
-e DOCKER_INFLUXDB_INIT_PASSWORD=${influxdbConfig.password} \
-e DOCKER_INFLUXDB_INIT_ORG=dtaas \
-e DOCKER_INFLUXDB_INIT_BUCKET=dtaas \
-e INFLUXD_TLS_CERT=/etc/ssl/fullchain.pem \
-e INFLUXD_TLS_KEY=/etc/ssl/privkey.pem \
influxdb:2.7`;
log(chalk.green("InfluxDB server docker container started successfully")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The current services.js has two limitations.
deploy/docker/
installation proceduresThe text was updated successfully, but these errors were encountered: