Skip to content
Snippets Groups Projects
Commit e436145c authored by jurgenhaas's avatar jurgenhaas
Browse files

ansible-playbooks/general#85 Make sure cli arguments have an explicit order in scripts

parent 8bf04cb7
Branches
No related tags found
No related merge requests found
Pipeline #9721 passed
Showing
with 47 additions and 46 deletions
...@@ -35,13 +35,14 @@ class Script: ...@@ -35,13 +35,14 @@ class Script:
prefix = '--' if parserType == 'options' else '' prefix = '--' if parserType == 'options' else ''
if parserType in script_def: if parserType in script_def:
for item in script_def[parserType]: for item in script_def[parserType]:
print('%s / %s' % (parserType, item)) name = item['name']
for kw in script_def[parserType][item]: item.pop('name')
if isinstance(script_def[parserType][item][kw], dict) and 'exec' in script_def[parserType][item][kw]: for kw in item:
if isinstance(item[kw], dict) and 'exec' in item[kw]:
result = None result = None
exec(script_def[parserType][item][kw]['exec']) exec(item[kw]['exec'])
script_def[parserType][item][kw] = result item[kw] = result
parser.add_argument(prefix + item, **script_def[parserType][item]) parser.add_argument(prefix + name, **item)
def ignoresInventory(self): def ignoresInventory(self):
......
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
description: Quickly configure Apache description: Quickly configure Apache
cli: cli:
options: options:
application: - name: application
default: apache default: apache
help: The application to configure Apache for, e.g. apache, drupal, matomo, nextcloud, kibana help: The application to configure Apache for, e.g. apache, drupal, matomo, nextcloud, kibana
site: - name: site
default: no default: no
help: The id of a site (only useful with certain applications like Drupal or Matomo) help: The id of a site (only useful with certain applications like Drupal or Matomo)
arguments: arguments:
......
...@@ -3,16 +3,16 @@ ...@@ -3,16 +3,16 @@
description: Pin, unpin or show status of packages description: Pin, unpin or show status of packages
cli: cli:
arguments: arguments:
mode: - name: mode
choices: choices:
- status - status
- pin - pin
- unpin - unpin
help: Mode for the pinning help: Mode for the pinning
package: - name: package
help: Name of the package help: Name of the package
options: options:
version: - name: version
default: '*' default: '*'
help: Version for which you want to pin help: Version for which you want to pin
arguments: arguments:
......
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
description: Find big files / directories description: Find big files / directories
cli: cli:
options: options:
depth: - name: depth
default: 5 default: 5
help: How many directories deep this should parse help: How many directories deep this should parse
threshold: - name: threshold
default: 1G default: 1G
help: Only show directories bigger than this help: Only show directories bigger than this
command: command:
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
description: Run a custom playbook from the inventory description: Run a custom playbook from the inventory
cli: cli:
arguments: arguments:
playbook: - name: playbook
help: Name of the playbook help: Name of the playbook
arguments: arguments:
custom: yes custom: yes
...@@ -3,14 +3,14 @@ ...@@ -3,14 +3,14 @@
description: Quickly configure Drupal sites description: Quickly configure Drupal sites
cli: cli:
arguments: arguments:
limit: - name: limit
default: no default: no
help: The hostname on which to re-reploy Drupal help: The hostname on which to re-reploy Drupal
site: - name: site
default: no default: no
help: The id of a site help: The id of a site
options: options:
quick: - name: quick
action: store_true action: store_true
default: no default: no
help: Only Drupal itself, not the CLI or JailKit help: Only Drupal itself, not the CLI or JailKit
......
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
description: Quickly re-deploy a Drupal site description: Quickly re-deploy a Drupal site
cli: cli:
arguments: arguments:
host: - name: host
default: no default: no
help: The hostname on which to re-reploy Drupal help: The hostname on which to re-reploy Drupal
site: - name: site
default: no default: no
help: The id of a site help: The id of a site
arguments: arguments:
......
...@@ -3,13 +3,13 @@ ...@@ -3,13 +3,13 @@
description: Dump and download Drupal database description: Dump and download Drupal database
cli: cli:
arguments: arguments:
host: - name: host
default: no default: no
help: The hostname of the Drupal site help: The hostname of the Drupal site
site: - name: site
default: no default: no
help: The id of a site help: The id of a site
dumpfilename: - name: dumpfilename
default: no default: no
help: The filename of the downloaded dump file help: The filename of the downloaded dump file
arguments: arguments:
......
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
description: Launch a Drupal site by creating certs, configure HaProxy, Apache and Drupal description: Launch a Drupal site by creating certs, configure HaProxy, Apache and Drupal
cli: cli:
arguments: arguments:
host: - name: host
default: no default: no
help: The hostname on which to launch Drupal help: The hostname on which to launch Drupal
site: - name: site
default: no default: no
help: The id of a site help: The id of a site
defaults: defaults:
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
description: Switch Firewall to unprotected mode for a period of time description: Switch Firewall to unprotected mode for a period of time
cli: cli:
options: options:
unprotect-period: - name: unprotect-period
default: no default: no
help: Number of minutes before the firewall goes into protected mode again help: Number of minutes before the firewall goes into protected mode again
arguments: arguments:
......
...@@ -3,40 +3,40 @@ ...@@ -3,40 +3,40 @@
description: Initially setup a new host description: Initially setup a new host
cli: cli:
arguments: arguments:
host: - name: host
help: Name of the host to be created help: Name of the host to be created
options: options:
user: - name: user
action: store action: store
default: default:
exec: | exec: |
result = os.environ['USER'] result = os.environ['USER']
help: The username of the first created admin user help: The username of the first created admin user
root: - name: root
action: store action: store
default: root default: root
help: The username to use initially help: The username to use initially
key: - name: key
action: store action: store
help: File name with the private key to be used initially help: File name with the private key to be used initially
groups: groups:
Cloud: Cloud:
description: When installing through a cloud provider, use these options description: When installing through a cloud provider, use these options
options: options:
cloud: - name: cloud
action: store action: store
choices: choices:
- ec2 - ec2
- jiffybox - jiffybox
- linode - linode
help: The cloud provider help: The cloud provider
groups: - name: groups
action: store action: store
help: The inventory groups for the host as comma separated list help: The inventory groups for the host as comma separated list
Non Cloud: Non Cloud:
description: When installing directly, use these options description: When installing directly, use these options
options: options:
ip: - name: ip
action: store action: store
help: The ip address of the host, only required if not installed in the cloud help: The ip address of the host, only required if not installed in the cloud
arguments: arguments:
......
...@@ -3,20 +3,20 @@ ...@@ -3,20 +3,20 @@
description: Initially setup a new Raspberry Pi description: Initially setup a new Raspberry Pi
cli: cli:
arguments: arguments:
host: - name: host
help: Name of the Pi to be created help: Name of the Pi to be created
options: options:
user: - name: user
action: store action: store
default: default:
exec: | exec: |
result = os.environ['USER'] result = os.environ['USER']
help: The username of the first created admin user help: The username of the first created admin user
root: - name: root
action: store action: store
default: pi default: pi
help: The username to use initially help: The username to use initially
key: - name: key
action: store action: store
help: File name with the private key to be used initially help: File name with the private key to be used initially
arguments: arguments:
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
description: Force updating all Jails description: Force updating all Jails
cli: cli:
options: options:
site: - name: site
default: no default: no
help: The id of a site if only one of the defined sites should be updated help: The id of a site if only one of the defined sites should be updated
defaults: defaults:
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
description: Init and update users in Jails description: Init and update users in Jails
cli: cli:
options: options:
site: - name: site
default: no default: no
help: The id of a site if only one of the defined sites should be updated help: The id of a site if only one of the defined sites should be updated
defaults: defaults:
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
description: Lists hosts and IP addresses description: Lists hosts and IP addresses
cli: cli:
options: options:
ip: - name: ip
default: no default: no
help: An optional IP to limit the assertion to that single IP help: An optional IP to limit the assertion to that single IP
arguments: arguments:
......
...@@ -4,12 +4,12 @@ description: Update local hosts file and SSH config, then call script hosts ...@@ -4,12 +4,12 @@ description: Update local hosts file and SSH config, then call script hosts
inventory-given-by-script: yes inventory-given-by-script: yes
cli: cli:
options: options:
host: - name: host
action: store action: store
default: default:
exec: | exec: |
result = socket.gethostname() result = socket.gethostname()
user: - name: user
action: store action: store
default: default:
exec: | exec: |
......
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
description: Quickly update matomo sites description: Quickly update matomo sites
cli: cli:
options: options:
reset: - name: reset
action: store_true action: store_true
default: no default: no
help: If True the existing directories get deleted first help: If True the existing directories get deleted first
site: - name: site
default: no default: no
help: The id of a site if matomo should be updated only for one of the defined sites help: The id of a site if matomo should be updated only for one of the defined sites
defaults: defaults:
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
description: Quickly update NetData description: Quickly update NetData
cli: cli:
options: options:
reset: - name: reset
action: store_true action: store_true
default: no default: no
help: If True the existing directories get deleted first help: If True the existing directories get deleted first
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
description: Install a new NextCloud site description: Install a new NextCloud site
cli: cli:
arguments: arguments:
site: - name: site
help: The id of the site to install help: The id of the site to install
defaults: defaults:
limit: webserver limit: webserver
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
description: Quickly update NextCloud plugins description: Quickly update NextCloud plugins
cli: cli:
options: options:
site: - name: site
default: no default: no
help: The id of a site if plugins should be updated only for one of the defined sites help: The id of a site if plugins should be updated only for one of the defined sites
defaults: defaults:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment