Commit e436145c authored by Jürgen Haas's avatar Jürgen Haas

#85 Make sure cli arguments have an explicit order in scripts

parent 8bf04cb7
Pipeline #9721 passed with stage
in 8 minutes and 5 seconds
......@@ -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):
......
......@@ -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:
......
......@@ -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:
......
......@@ -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:
......
......@@ -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
......@@ -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
......
......@@ -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:
......
......@@ -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:
......
......@@ -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:
......
......@@ -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:
......
......@@ -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:
......
......@@ -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:
......
......@@ -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:
......
......@@ -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:
......
......@@ -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:
......
......@@ -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: |
......
......@@ -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:
......
......@@ -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
......
......@@ -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
......
......@@ -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:
......
......@@ -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:
......
......@@ -3,8 +3,8 @@
description: Run a specific playbook
cli:
arguments:
playbook:
- name: playbook
help: Playbook to execute
options:
custom:
- name: custom
default: no
......@@ -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
......
......@@ -3,7 +3,7 @@
description: Run a specific role only
cli:
arguments:
role:
- name: role
help: Role to execute
arguments:
playbook: role
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
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