Commit 37e529d9 authored by nanahira's avatar nanahira

fix

parent dac9e2d1
...@@ -96,16 +96,19 @@ class InventoryBuilder { ...@@ -96,16 +96,19 @@ class InventoryBuilder {
host.wgPublickey = await this.wgPublickey(host.wgPrivateKey); host.wgPublickey = await this.wgPublickey(host.wgPrivateKey);
} }
this.vars = await this.loadUtilities(); this.vars = await this.loadUtilities();
const inventoryValue = { hosts: Object.fromEntries(Object.values(this.hosts).map(host => [host.name, this.getHostConnectionInfo(host)])) }; const inventoryValue = { wg: {hosts: Object.fromEntries(Object.values(this.hosts).map(host => [host.name, this.getHostConnectionInfo(host)]))} };
await fs.promises.writeFile('result/inventory.yaml', YAML.stringify(inventoryValue)); await fs.promises.writeFile('result/inventory.yaml', YAML.stringify(inventoryValue));
// console.log(Object.values(this.hosts)); // console.log(Object.values(this.hosts));
const hostsArray = await Promise.all(Object.values(this.hosts).map(async (h) => [h.name, await this.host_vars(h)])); const hosts = await Promise.all(Object.values(this.hosts).map(async (h) => ({
name: h.name,
vars: await this.host_vars(h)
})));
//const hosts = Object.fromEntries(hostsArray); //const hosts = Object.fromEntries(hostsArray);
//await fs.promises.writeFile('result/inventory.yaml', YAML.stringify({ //await fs.promises.writeFile('result/inventory.yaml', YAML.stringify({
// wg: { hosts } // wg: { hosts }
//})); //}));
await fs.promises.writeFile('result/global-vars.yaml', YAML.stringify(this.vars)); await fs.promises.writeFile('result/global-vars.yaml', YAML.stringify(this.vars));
await Promise.all(hostsArray.map(host => fs.promises.writeFile(`result/vars-${host[0]}.yaml`, YAML.stringify(host[1])))); await Promise.all(hosts.map(host => fs.promises.writeFile(`result/vars-${host[0]}.yaml`, YAML.stringify(host[1]))));
} }
async loadUtilities() { async loadUtilities() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment