Paramétrage du nom de la branche souhaité

This commit is contained in:
Olivier Navas 2024-11-29 13:03:26 +01:00
parent 08737d7adf
commit b7f16c46d5
3 changed files with 7 additions and 8 deletions

View file

@ -2,6 +2,8 @@
base_path: ansible base_path: ansible
### Titre du menu ### Titre du menu
title: Menu de configuration Libretic title: Menu de configuration Libretic
### Branche git souhaitée - avertit si la branche constatée est différente
git_branch: main
### Liste des playbooks ansible ### Liste des playbooks ansible
# ansible_playbooks: # ansible_playbooks:

View file

@ -18,7 +18,7 @@ def setFQDN(fqdn):
### Cartouche de status ### Cartouche de status
def print_status(menuTitle): def print_status(menuTitle, gitBranch):
# Récupération des infos # Récupération des infos
hostname = getHostName() hostname = getHostName()
domain = getDomain() domain = getDomain()
@ -33,9 +33,8 @@ def print_status(menuTitle):
table.add_column("Paramètre", style="bold magenta") table.add_column("Paramètre", style="bold magenta")
table.add_column("Valeur") table.add_column("Valeur")
table.add_column("Statut", justify="center") table.add_column("Statut", justify="center")
table.add_row("Environnement du poste", currentBranch, "[green]OK" if currentBranch == "main" else "[yellow]Attention") table.add_row("Environnement du poste", currentBranch, "[green]OK" if currentBranch == gitBranch else "[yellow]Attention")
table.add_row("Hostname", hostname, "[green]OK" if hostname != "unassigned-hostname" else "[red]KO") table.add_row("Hostname", hostname, "[green]OK" if hostname != "unassigned-hostname" else "[red]KO")
console.print(table) console.print(table)
console.print() console.print()

View file

@ -102,10 +102,8 @@ def main():
config = readConfig("config.yml") config = readConfig("config.yml")
currentBranch = GitActions.getBranch() currentBranch = GitActions.getBranch()
if 'title' in config: title = config['title'] if 'title' in config else "Menu de configuration linuxinstaller"
title=config['title'] gitBranch = config['git_branch'] if 'git_branch' in config else "main"
else:
title="Menu de configuration linuxinstaller"
parser = argparse.ArgumentParser(description=title) parser = argparse.ArgumentParser(description=title)
parser.add_argument("--tags", help="Exécute les playbooks portant ces étiquettes", action="extend", nargs="+", type=str) parser.add_argument("--tags", help="Exécute les playbooks portant ces étiquettes", action="extend", nargs="+", type=str)
@ -152,7 +150,7 @@ def main():
while not cmdlineOptionPassed: while not cmdlineOptionPassed:
PythonActions.print_status(title) PythonActions.print_status(title, gitBranch)
console = Console() console = Console()
console.print("Choisir une des options suivantes", style="bold blue") console.print("Choisir une des options suivantes", style="bold blue")
action = inquirer.select( action = inquirer.select(