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
No related branches found
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:
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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment