Skip to content
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

chore: ansible improvements #254

Merged
merged 11 commits into from
Aug 24, 2021
2 changes: 2 additions & 0 deletions ansible/ansible.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ host_key_checking = False
gather_timeout = 20
timeout = 50
forks = 20
stdout_callback = yaml
bin_ansible_callbacks = True

[ssh_connection]
ssh_args = "-o ControlMaster=auto -o ControlPersist=60s"
Expand Down
1 change: 1 addition & 0 deletions ansible/roles/dashd/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
- '{{ dashd_home }}:/dash'
network_mode: host
command: 'dashd -conf={{ dashd_home }}/.dashcore/dash.conf -datadir={{ dashd_home }}/.dashcore'
container_default_behavior: compatibility

- name: wait for rpc to be available
shell: dash-cli getblockchaininfo
Expand Down
6 changes: 3 additions & 3 deletions ansible/roles/insight/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
state: present
restarted: yes
pull: yes

register: output

- name: check Insight container
assert:
that: 'insight.insight.state.running'
that: 'output.services.insight.insight.state.running'

- name: check Insight Proxy container
assert:
that: 'insight_proxy.insight_proxy.state.running'
that: 'output.services.insight_proxy.insight_proxy.state.running'
2 changes: 1 addition & 1 deletion lib/cli/services.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function services_list() {

cd terraform/aws

terraform output services
terraform output -raw services

cd ../..
}
4 changes: 2 additions & 2 deletions lib/cli/terraform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function terraform_run_command() {

# Create the inventory file for Ansible

terraform output ansible_inventory > ../../${INVENTORY_FILE}
terraform output -raw ansible_inventory > ../../${INVENTORY_FILE}

cd ../../
}
Expand All @@ -74,7 +74,7 @@ function terraform_output_inventory() {

terraform workspace select "$NETWORK_NAME"

terraform output ansible_inventory > ../../${INVENTORY_FILE}
terraform output -raw ansible_inventory > ../../${INVENTORY_FILE}

echo "Ansible inventory file successfully created."

Expand Down
7 changes: 5 additions & 2 deletions lib/configGenerator/generateAnsibleConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const fs = require('fs').promises;

const { PrivateKey } = require('@dashevo/dashcore-lib');

const { PrivateKey: BlsPrivateKey } = require('bls-signatures');
const BlsSignatures = require('bls-signatures');

const yaml = require('js-yaml');

Expand Down Expand Up @@ -71,6 +71,9 @@ async function generateAnsibleConfig(network, networkName, masternodesCount, see
const ownerPrivateKey = new PrivateKey(undefined, network);
const collateralPrivateKey = new PrivateKey(undefined, network);

const blsSignatures = await BlsSignatures();
const { PrivateKey: BlsPrivateKey } = blsSignatures;

const randomBytes = new Uint8Array(crypto.randomBytes(256));
const operatorPrivateKey = BlsPrivateKey.fromBytes(randomBytes, true);
const operatorPublicKey = operatorPrivateKey.getPublicKey();
Expand Down Expand Up @@ -129,7 +132,7 @@ async function generateAnsibleConfig(network, networkName, masternodesCount, see
config.seed_nodes[`seed-${i}`].node_key = generateTenderdashNodeKeys();
}

const data = yaml.safeDump(config);
const data = yaml.dump(config);

await fs.writeFile(`networks/${networkName}.yml`, `---\n\n${data}`);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/test/readYamlFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const yaml = require('js-yaml');
module.exports = function readYamlFiles(...files) {
const objectsArray = files.map((file) => {
const fileString = fs.readFileSync(file, 'utf8');
return yaml.safeLoad(fileString);
return yaml.load(fileString);
});

return merge(...objectsArray);
Expand Down
2 changes: 1 addition & 1 deletion lib/test/wait.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = function wait(ms) {
return new Promise(res => setTimeout(res, ms));
return new Promise((res) => setTimeout(res, ms));
};
Loading