Use new arguments and fix Init playbook location in Infra command

This commit is contained in:
Christer Warén
2025-12-29 15:09:07 +02:00
parent cf9bc49c27
commit a9e5b2c336
2 changed files with 28 additions and 6 deletions

View File

@@ -54,6 +54,8 @@ wx-infra(){
then then
wxi-header "Init" h3 wxi-header "Init" h3
hostname=${args['hostname']}
if [[ -z ${args['3']} ]] if [[ -z ${args['3']} ]]
then then
tags=init tags=init
@@ -61,15 +63,24 @@ wx-infra(){
tags=${args['3']} tags=${args['3']}
fi fi
ansible-playbook $INFRA_VAULT playbooks/init.yml -t $tags --limit "${args['limit']}" ansible-playbook $INFRA_VAULT init.yml --tags $tags --limit "$hostname"
elif [[ ${args['2']} == "manager" ]] elif [[ ${args['2']} == "manager" ]]
then then
if [[ -z ${args['hostname']} ]]
then
hostname="any"
else
hostname=${args['hostname']}
fi
operation=${args['operation']}
wxi-header "Manager" h3 wxi-header "Manager" h3
ansible-playbook $INFRA_VAULT manager.yml --extra-vars "${args['extra-vars']}" ansible-playbook $INFRA_VAULT manager.yml --tags $operation --extra-vars "host=$hostname operation=$operation"
else else
wxi-header "Playbooks" h3 wxi-header "Playbooks" h3
hostname=${args['hostname']}
tags=${args['2']} tags=${args['2']}
ansible-playbook $INFRA_VAULT playbooks.yml -t $tags --limit "${args['limit']}" ansible-playbook $INFRA_VAULT playbooks.yml --tags $tags --limit "$hostname"
fi fi
cd "$OLDPWD" cd "$OLDPWD"
fi fi

17
wx
View File

@@ -326,6 +326,8 @@ wx-infra(){
then then
wxi-header "Init" h3 wxi-header "Init" h3
hostname=${args['hostname']}
if [[ -z ${args['3']} ]] if [[ -z ${args['3']} ]]
then then
tags=init tags=init
@@ -333,15 +335,24 @@ wx-infra(){
tags=${args['3']} tags=${args['3']}
fi fi
ansible-playbook $INFRA_VAULT playbooks/init.yml -t $tags --limit "${args['limit']}" ansible-playbook $INFRA_VAULT init.yml --tags $tags --limit "$hostname"
elif [[ ${args['2']} == "manager" ]] elif [[ ${args['2']} == "manager" ]]
then then
if [[ -z ${args['hostname']} ]]
then
hostname="any"
else
hostname=${args['hostname']}
fi
operation=${args['operation']}
wxi-header "Manager" h3 wxi-header "Manager" h3
ansible-playbook $INFRA_VAULT manager.yml --extra-vars "${args['extra-vars']}" ansible-playbook $INFRA_VAULT manager.yml --tags $operation --extra-vars "host=$hostname operation=$operation"
else else
wxi-header "Playbooks" h3 wxi-header "Playbooks" h3
hostname=${args['hostname']}
tags=${args['2']} tags=${args['2']}
ansible-playbook $INFRA_VAULT playbooks.yml -t $tags --limit "${args['limit']}" ansible-playbook $INFRA_VAULT playbooks.yml --tags $tags --limit "$hostname"
fi fi
cd "$OLDPWD" cd "$OLDPWD"
fi fi