diff --git a/lib/script.py b/lib/script.py index 45db899c24df764cff12d8abed5b10521a260e80..815c2fe0080cd62451f2df935cc7c9cf86e85270 100644 --- a/lib/script.py +++ b/lib/script.py @@ -35,13 +35,14 @@ class Script: prefix = '--' if parserType == 'options' else '' if parserType in script_def: for item in script_def[parserType]: - print('%s / %s' % (parserType, item)) - for kw in script_def[parserType][item]: - if isinstance(script_def[parserType][item][kw], dict) and 'exec' in script_def[parserType][item][kw]: + name = item['name'] + item.pop('name') + for kw in item: + if isinstance(item[kw], dict) and 'exec' in item[kw]: result = None - exec(script_def[parserType][item][kw]['exec']) - script_def[parserType][item][kw] = result - parser.add_argument(prefix + item, **script_def[parserType][item]) + exec(item[kw]['exec']) + item[kw] = result + parser.add_argument(prefix + name, **item) def ignoresInventory(self): diff --git a/scripts/apache-config.yml b/scripts/apache-config.yml index 7860361e171d2a167b3d52a30a13f6861af201f5..ff76ad1a5a1a6b71d471cb254cbd26a7f18d27c6 100644 --- a/scripts/apache-config.yml +++ b/scripts/apache-config.yml @@ -3,10 +3,10 @@ description: Quickly configure Apache cli: options: - application: + - name: application default: apache help: The application to configure Apache for, e.g. apache, drupal, matomo, nextcloud, kibana - site: + - name: site default: no help: The id of a site (only useful with certain applications like Drupal or Matomo) arguments: diff --git a/scripts/apt-pin.yml b/scripts/apt-pin.yml index 286feb649d5586f5d7bc2a8b72766b3f33ac4b8f..299b0142d4ae1a067e5cda8d930fdba2b0f59c3a 100644 --- a/scripts/apt-pin.yml +++ b/scripts/apt-pin.yml @@ -3,16 +3,16 @@ description: Pin, unpin or show status of packages cli: arguments: - mode: + - name: mode choices: - status - pin - unpin help: Mode for the pinning - package: + - name: package help: Name of the package options: - version: + - name: version default: '*' help: Version for which you want to pin arguments: diff --git a/scripts/bigfiles.yml b/scripts/bigfiles.yml index aba7cd8d0a29a996829106c27fbf3d4e69b24f21..1a25ba78e19c315357abc313279704d97ff372a1 100644 --- a/scripts/bigfiles.yml +++ b/scripts/bigfiles.yml @@ -3,10 +3,10 @@ description: Find big files / directories cli: options: - depth: + - name: depth default: 5 help: How many directories deep this should parse - threshold: + - name: threshold default: 1G help: Only show directories bigger than this command: diff --git a/scripts/custom.yml b/scripts/custom.yml index ee0300d78d43abd0267a686158b623ec3d381ce0..3ff962da77b611798e075c66bad80e736b1c726a 100644 --- a/scripts/custom.yml +++ b/scripts/custom.yml @@ -3,7 +3,7 @@ description: Run a custom playbook from the inventory cli: arguments: - playbook: + - name: playbook help: Name of the playbook arguments: custom: yes diff --git a/scripts/drupal-config.yml b/scripts/drupal-config.yml index cd00070e117addf5f8774ad3c3b6f795c8fe9fb0..ef7aa1c9d0a441c2115c5f71eada579356153a71 100644 --- a/scripts/drupal-config.yml +++ b/scripts/drupal-config.yml @@ -3,14 +3,14 @@ description: Quickly configure Drupal sites cli: arguments: - limit: + - name: limit default: no help: The hostname on which to re-reploy Drupal - site: + - name: site default: no help: The id of a site options: - quick: + - name: quick action: store_true default: no help: Only Drupal itself, not the CLI or JailKit diff --git a/scripts/drupal-deploy.yml b/scripts/drupal-deploy.yml index a0558a321ce474480838f020e73b0712bdc76ce4..a34197fe5848e2d9206de95ad0b2a82f077f2cda 100644 --- a/scripts/drupal-deploy.yml +++ b/scripts/drupal-deploy.yml @@ -3,10 +3,10 @@ description: Quickly re-deploy a Drupal site cli: arguments: - host: + - name: host default: no help: The hostname on which to re-reploy Drupal - site: + - name: site default: no help: The id of a site arguments: diff --git a/scripts/drupal-dump-db.yml b/scripts/drupal-dump-db.yml index a9ec4d03a6844dc90fd2bddd3fa3fc3023dcc9f6..5af30d9dc5cacc54ca49d5603793605cc968dd04 100644 --- a/scripts/drupal-dump-db.yml +++ b/scripts/drupal-dump-db.yml @@ -3,13 +3,13 @@ description: Dump and download Drupal database cli: arguments: - host: + - name: host default: no help: The hostname of the Drupal site - site: + - name: site default: no help: The id of a site - dumpfilename: + - name: dumpfilename default: no help: The filename of the downloaded dump file arguments: diff --git a/scripts/drupal-launch.yml b/scripts/drupal-launch.yml index 4400626ff749bea59718390a610d981c64011359..f64e3c69ed280dcf88af8dc73eb2da4ee082cc16 100644 --- a/scripts/drupal-launch.yml +++ b/scripts/drupal-launch.yml @@ -3,10 +3,10 @@ description: Launch a Drupal site by creating certs, configure HaProxy, Apache and Drupal cli: arguments: - host: + - name: host default: no help: The hostname on which to launch Drupal - site: + - name: site default: no help: The id of a site defaults: diff --git a/scripts/firewall-unprotect.yml b/scripts/firewall-unprotect.yml index d23a314895ad07685ca2794583f43fb0218ab487..642472e5bd94e09f643948d247757d7f66007603 100644 --- a/scripts/firewall-unprotect.yml +++ b/scripts/firewall-unprotect.yml @@ -3,7 +3,7 @@ description: Switch Firewall to unprotected mode for a period of time cli: options: - unprotect-period: + - name: unprotect-period default: no help: Number of minutes before the firewall goes into protected mode again arguments: diff --git a/scripts/inithost.yml b/scripts/inithost.yml index 90cdc1eb8d404d79e93e74d993a4bb405a386484..8ff88aacfca936e5bc768524e103314f9cd60893 100644 --- a/scripts/inithost.yml +++ b/scripts/inithost.yml @@ -3,40 +3,40 @@ description: Initially setup a new host cli: arguments: - host: + - name: host help: Name of the host to be created options: - user: + - name: user action: store default: exec: | result = os.environ['USER'] help: The username of the first created admin user - root: + - name: root action: store default: root help: The username to use initially - key: + - name: key action: store help: File name with the private key to be used initially groups: Cloud: description: When installing through a cloud provider, use these options options: - cloud: + - name: cloud action: store choices: - ec2 - jiffybox - linode help: The cloud provider - groups: + - name: groups action: store help: The inventory groups for the host as comma separated list Non Cloud: description: When installing directly, use these options options: - ip: + - name: ip action: store help: The ip address of the host, only required if not installed in the cloud arguments: diff --git a/scripts/initpi.yml b/scripts/initpi.yml index c27178d15c919cc9824e1314c69d01fb3cd0f168..a801d4c51c6c5aac77db491289731be5d82f4903 100644 --- a/scripts/initpi.yml +++ b/scripts/initpi.yml @@ -3,20 +3,20 @@ description: Initially setup a new Raspberry Pi cli: arguments: - host: + - name: host help: Name of the Pi to be created options: - user: + - name: user action: store default: exec: | result = os.environ['USER'] help: The username of the first created admin user - root: + - name: root action: store default: pi help: The username to use initially - key: + - name: key action: store help: File name with the private key to be used initially arguments: diff --git a/scripts/jailkit-update.yml b/scripts/jailkit-update.yml index 9c4c48d60afcb92841967daa47a3943b96d12721..858fae2ad8561080794b98b5a92b886fc381c0cb 100644 --- a/scripts/jailkit-update.yml +++ b/scripts/jailkit-update.yml @@ -3,7 +3,7 @@ description: Force updating all Jails cli: options: - site: + - name: site default: no help: The id of a site if only one of the defined sites should be updated defaults: diff --git a/scripts/jailkit-user.yml b/scripts/jailkit-user.yml index 7df1b1fc2d591ee944f624b32ef64b2704c9da14..734744d434bd6ba78649b942f7f1bd6bbff4805f 100644 --- a/scripts/jailkit-user.yml +++ b/scripts/jailkit-user.yml @@ -3,7 +3,7 @@ description: Init and update users in Jails cli: options: - site: + - name: site default: no help: The id of a site if only one of the defined sites should be updated defaults: diff --git a/scripts/lists.yml b/scripts/lists.yml index ccea246350e73315dc33efe99889d044a875b188..ea2b18e3000be306c72adfd0127de95437725a52 100644 --- a/scripts/lists.yml +++ b/scripts/lists.yml @@ -3,7 +3,7 @@ description: Lists hosts and IP addresses cli: options: - ip: + - name: ip default: no help: An optional IP to limit the assertion to that single IP arguments: diff --git a/scripts/localhost.yml b/scripts/localhost.yml index c063ae8bc8b7fba139ce4bc2fc13f5ec708b4fa8..c454c5a4bd327150d0bdd89c6cbd82f6bad96656 100644 --- a/scripts/localhost.yml +++ b/scripts/localhost.yml @@ -4,12 +4,12 @@ description: Update local hosts file and SSH config, then call script hosts inventory-given-by-script: yes cli: options: - host: + - name: host action: store default: exec: | result = socket.gethostname() - user: + - name: user action: store default: exec: | diff --git a/scripts/matomo.yml b/scripts/matomo.yml index 5d27e6e8d24ba8aa3ebc745e071a79906769e965..56d165643a1876fa09b9b2af25ef493833373a6d 100644 --- a/scripts/matomo.yml +++ b/scripts/matomo.yml @@ -3,11 +3,11 @@ description: Quickly update matomo sites cli: options: - reset: + - name: reset action: store_true default: no help: If True the existing directories get deleted first - site: + - name: site default: no help: The id of a site if matomo should be updated only for one of the defined sites defaults: diff --git a/scripts/netdata.yml b/scripts/netdata.yml index 9a6ccb0c958ef2fc67f1b09dc22b98e68056862d..202276c4172e4dc761060815031103aaf31e7c31 100644 --- a/scripts/netdata.yml +++ b/scripts/netdata.yml @@ -3,7 +3,7 @@ description: Quickly update NetData cli: options: - reset: + - name: reset action: store_true default: no help: If True the existing directories get deleted first diff --git a/scripts/nextcloud-install.yml b/scripts/nextcloud-install.yml index 92070a6df901579c055e0944ba4a1d9c58fd06b1..034128e8781a15b7ffc229483a5059df61deddfa 100644 --- a/scripts/nextcloud-install.yml +++ b/scripts/nextcloud-install.yml @@ -3,7 +3,7 @@ description: Install a new NextCloud site cli: arguments: - site: + - name: site help: The id of the site to install defaults: limit: webserver diff --git a/scripts/nextcloud-plugins.yml b/scripts/nextcloud-plugins.yml index 214a052f19d3791c97991dec11155748e5260575..61cb40d76777a518b0eae87d0a288804b8d884db 100644 --- a/scripts/nextcloud-plugins.yml +++ b/scripts/nextcloud-plugins.yml @@ -3,7 +3,7 @@ description: Quickly update NextCloud plugins cli: options: - site: + - name: site default: no help: The id of a site if plugins should be updated only for one of the defined sites defaults: diff --git a/scripts/nextcloud.yml b/scripts/nextcloud.yml index ae510bc2e6c11fb09721d2b426e28e22b5d3b101..21ed93a316c0bb7c83ba33a95d2768c5405a70a5 100644 --- a/scripts/nextcloud.yml +++ b/scripts/nextcloud.yml @@ -3,7 +3,7 @@ description: Quickly update NextCloud sites cli: options: - site: + - name: site default: no help: The id of a site if only one of the defined sites should be updated defaults: diff --git a/scripts/playbook.yml b/scripts/playbook.yml index e7700f2584af74b1b7679e923833c64bd16f1dbd..1e76550ed71dda65182d992db72dc4e2502e3aff 100644 --- a/scripts/playbook.yml +++ b/scripts/playbook.yml @@ -3,8 +3,8 @@ description: Run a specific playbook cli: arguments: - playbook: + - name: playbook help: Playbook to execute options: - custom: + - name: custom default: no diff --git a/scripts/removehost.yml b/scripts/removehost.yml index 8ca9a94d0b5951d412430194352ca461d83f2f2c..e42bf9ebd56f66c2b32299b9d82ec506a99d3c46 100644 --- a/scripts/removehost.yml +++ b/scripts/removehost.yml @@ -3,10 +3,10 @@ description: Remove a host and delete the instance in the cloud cli: arguments: - host: + - name: host help: Name of the host to be removed options: - cloud: + - name: cloud action: store choices: - ec2 diff --git a/scripts/role.yml b/scripts/role.yml index a87f4f165f8f304c4226d7b23ea9500791a22045..a20dbdf745cd48a6b67e78177599c76fb2046079 100644 --- a/scripts/role.yml +++ b/scripts/role.yml @@ -3,7 +3,7 @@ description: Run a specific role only cli: arguments: - role: + - name: role help: Role to execute arguments: playbook: role diff --git a/scripts/sanity.yml b/scripts/sanity.yml index 0c2dd6b1b02593b73d0f667223bddfd8c7269da5..845d7747fb4a1c9cbd9b1f4703148f581b5a4a97 100644 --- a/scripts/sanity.yml +++ b/scripts/sanity.yml @@ -3,7 +3,7 @@ description: Check for updates, upgrade and reboot hosts cli: arguments: - mode: + - name: mode choices: - check - upgrade @@ -11,11 +11,11 @@ cli: - reschedule help: Mode for the sanity play options: - force: + - name: force action: store_true default: no help: Force to also reboot proxy servers - withoutreason: + - name: withoutreason action: store_true default: no help: Force reboot even if not required diff --git a/scripts/setup-local.yml b/scripts/setup-local.yml index c1fb9415bf60c51567aaa843cf54f45f4ff7d408..01963c3f5f7f21cc1489fd84a31ed53c2a53f0a3 100644 --- a/scripts/setup-local.yml +++ b/scripts/setup-local.yml @@ -4,10 +4,10 @@ description: Setup and update the Paragon wrapper for Ansible ignore-inventory: yes cli: arguments: - inventory: + - name: inventory help: Name of the company in lowercase to specify the inventory options: - username: + - name: username default: exec: | import ConfigParser @@ -20,7 +20,7 @@ cli: if not result: result = os.environ.get('USER') help: Name of the remote user if different from your local username - skip-os-tasks: + - name: skip-os-tasks action: store_false default: yes help: Skip all tasks that aim to install os components in order to do that manually diff --git a/scripts/userlock.yml b/scripts/userlock.yml index 181aad115c5402f7702e9ae7d0db87c6f9813387..dfac3d4486ac9619ca3856adf1dbd88f31f4410c 100644 --- a/scripts/userlock.yml +++ b/scripts/userlock.yml @@ -3,7 +3,7 @@ description: Lock user on all hosts cli: arguments: - lockuser_username: + - name: lockuser_username help: Existing username who should be locked defaults: limit: all diff --git a/scripts/userpwd.yml b/scripts/userpwd.yml index 73d07cf30c22f25e01c57ba1bdb6a269a9f0bcea..b74d572b9d5960b436e09c0c80a102148faf18ff 100644 --- a/scripts/userpwd.yml +++ b/scripts/userpwd.yml @@ -3,9 +3,9 @@ description: Set user password on all hosts cli: arguments: - username: + - name: username help: Existing username for whom to set a new password - password: + - name: password help: New password for the given user defaults: limit: all diff --git a/scripts/userunlock.yml b/scripts/userunlock.yml index f885d2f15fd2e86211fefef1ed0f47b1cc335236..f624582b733cf2ece3302ef5b071e58f2075a9c9 100644 --- a/scripts/userunlock.yml +++ b/scripts/userunlock.yml @@ -3,7 +3,7 @@ description: Unlock user on all hosts cli: arguments: - lockuser_username: + - name: lockuser_username help: Existing username who should be unlocked defaults: limit: all