Commit 38c18c5e authored by nanahira's avatar nanahira

support no-update link

parent 1831a824
......@@ -89,13 +89,13 @@
vars:
conn: '{{item}}'
with_items: '{{ connections }}'
when: "not noUpdateLinks and (not onlyUpdateLink or item.name == onlyUpdateLink) and item.protocol == 'null'"
when: "not noUpdateLinks and item.protocol == 'null' and not item.noUpdate"
- name: 'loop through list from a variable'
include_tasks: 'protocols/{{item.protocol}}/configure.yaml'
vars:
conn: '{{item}}'
with_items: '{{ connections }}'
when: "not noUpdateLinks and (not onlyUpdateLink or item.name == onlyUpdateLink) and item.protocol != 'null'"
when: "not noUpdateLinks and item.protocol != 'null' and not item.noUpdate"
# end
- name: disable bug self-link
become: true
......
......@@ -25,6 +25,7 @@ class InventoryBuilder {
resolveCache: Map<string, string>;
resolver: dns.Resolver;
vars: any;
linksOnly: string[];
constructor() {
this.resolveCache = new Map();
......@@ -95,6 +96,9 @@ class InventoryBuilder {
for (const host of Object.values(this.hosts)) {
host.wgPublickey = await this.wgPublickey(host.wgPrivateKey);
}
if (process.env.ONLY_LINKS) {
this.linksOnly = process.env.ONLY_LINKS.split(",");
}
this.vars = await this.loadUtilities();
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));
......@@ -128,8 +132,7 @@ class InventoryBuilder {
const vars = {
routeLists: this.routeLists,
routeListNames: Object.keys(this.routeLists),
noUpdateLinks: !!process.env.NO_LINK,
onlyUpdateLink: process.env.ONLY_LINK || null
noUpdateLinks: !!process.env.NO_LINK
};
for (let col in raw_utility) {
vars[col] = raw_utility[col].value;
......@@ -346,6 +349,8 @@ class InventoryBuilder {
console.log(`${local.name} GW ${localGateway.isp} ${inbound ? '<' : '='}=${frpType === 'frps' ? 's' : '='}=[${protocol}]=${frpType === 'frpc' ? 's' : '='}=> ${remote.name} GW ${remoteGateway.isp}`);
}
const noUpdate = this.linksOnly && !this.linksOnly.includes(remote.name) && !this.linksOnly.includes(local.name)
return {
name,
metric,
......@@ -370,7 +375,8 @@ class InventoryBuilder {
ocType,
inbound,
outbound,
mtu
mtu,
noUpdate,
};
}
......
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