Dagger
Search

ansible

Ce module fournit des fonctions réutilisables pour gérer les déploiements Ansible
de manière portable et reproductible avec intégration Azure Key Vault

Le module utilise un pattern "builder" avec chaînage de fonctions :

dagger call container \
with-azure-credentials \
--client-id env:AZURE_CLIENT_ID \
--client-secret env:AZURE_CLIENT_SECRET \
--tenant-id env:AZURE_TENANT_ID \
with-inventory --hosts "host1.example.com,host2.example.com" \
with-playbook --playbook ./playbook.yml --project ./ANSIBLE-TEMPLATES \
run

Installation

dagger install dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/iac/ansible@35bf1ad02e27c3a7eb59c1d696eb74cf246e94c0

Entrypoint

Return Type
Ansible !
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/iac/ansible@35bf1ad02e27c3a7eb59c1d696eb74cf246e94c0 call \
func (m *MyModule) Example() *dagger.Ansible  {
	return dag.
			Ansible()
}
@function
def example() -> dagger.Ansible:
	return (
		dag.ansible()
	)
@func()
example(): Ansible {
	return dag
		.ansible()
}

Types

Ansible 🔗

container() 🔗

Container construit un conteneur Ansible à la volée avec toutes les dépendances C’est le point d’entrée pour construire une exécution Ansible

Return Type
Container !
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/iac/ansible@35bf1ad02e27c3a7eb59c1d696eb74cf246e94c0 call \
 container
func (m *MyModule) Example() *dagger.AnsibleContainer  {
	return dag.
			Ansible().
			Container()
}
@function
def example() -> dagger.AnsibleContainer:
	return (
		dag.ansible()
		.container()
	)
@func()
example(): AnsibleContainer {
	return dag
		.ansible()
		.container()
}

Container 🔗

AnsibleContainer encapsule un conteneur Ansible pour permettre le chaînage de méthodes

container() 🔗

Return Type
Container !
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/iac/ansible@35bf1ad02e27c3a7eb59c1d696eb74cf246e94c0 call \
 container \
 container
func (m *MyModule) Example() *dagger.Container  {
	return dag.
			Ansible().
			Container().
			Container()
}
@function
def example() -> dagger.Container:
	return (
		dag.ansible()
		.container()
		.container()
	)
@func()
example(): Container {
	return dag
		.ansible()
		.container()
		.container()
}

withAzureCredentials() 🔗

WithAzureCredentials configure les credentials Azure pour accéder au Key Vault Cette fonction est chainable et retourne un nouveau container

Exemple:

dagger call container ... \
  with-azure-credentials \
    --client-id env:AZURE_CLIENT_ID \
    --client-secret env:AZURE_CLIENT_SECRET \
    --tenant-id env:AZURE_TENANT_ID \
    --keyvault-name kv-azure-devops-002
Return Type
Container !
Arguments
NameTypeDefault ValueDescription
clientIdString !-Client ID Azure
clientSecretSecret !-Client Secret Azure
tenantIdString !-Tenant ID Azure
keyvaultNameString "kv-azure-devops-002"Nom du Key Vault Azure
keyvaultUriString "https://kv-azure-devops-002.vault.azure.net/"URI du Key Vault Azure
subscriptionIdString -Subscription ID Azure
sshKeyNameString "admincd24-ssh-key"Nom de la clé SSH dans le Key Vault
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/iac/ansible@35bf1ad02e27c3a7eb59c1d696eb74cf246e94c0 call \
 container \
 with-azure-credentials --client-id string --client-secret env:MYSECRET --tenant-id string
func (m *MyModule) Example(clientId string, clientSecret *dagger.Secret, tenantId string) *dagger.AnsibleContainer  {
	return dag.
			Ansible().
			Container().
			WithAzureCredentials(clientId, clientSecret, tenantId)
}
@function
def example(client_id: str, client_secret: dagger.Secret, tenant_id: str) -> dagger.AnsibleContainer:
	return (
		dag.ansible()
		.container()
		.with_azure_credentials(client_id, client_secret, tenant_id)
	)
@func()
example(clientId: string, clientSecret: Secret, tenantId: string): AnsibleContainer {
	return dag
		.ansible()
		.container()
		.withAzureCredentials(clientId, clientSecret, tenantId)
}

withInventory() 🔗

WithInventory génère un inventaire Ansible dynamique à partir d’une liste d’hôtes Cette fonction est chainable et retourne un nouveau container

Exemple:

dagger call container ... \
  with-inventory --hosts "host1.example.com,host2.example.com"
Return Type
Container !
Arguments
NameTypeDefault ValueDescription
hostsString !-Liste des hôtes cibles séparés par des virgules Exemple: "host1.example.com,host2.example.com,192.168.1.10"
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/iac/ansible@35bf1ad02e27c3a7eb59c1d696eb74cf246e94c0 call \
 container \
 with-inventory --hosts string
func (m *MyModule) Example(hosts string) *dagger.AnsibleContainer  {
	return dag.
			Ansible().
			Container().
			WithInventory(hosts)
}
@function
def example(hosts: str) -> dagger.AnsibleContainer:
	return (
		dag.ansible()
		.container()
		.with_inventory(hosts)
	)
@func()
example(hosts: string): AnsibleContainer {
	return dag
		.ansible()
		.container()
		.withInventory(hosts)
}

withInventoryFile() 🔗

WithInventoryFile utilise un fichier d’inventaire existant au lieu de générer un inventaire dynamique Cette fonction est chainable et retourne un nouveau container

Exemple:

dagger call container ... \
  with-inventory-file --inventory ./inventory.ini
Return Type
Container !
Arguments
NameTypeDefault ValueDescription
inventoryFile !-Fichier d'inventaire Ansible
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/iac/ansible@35bf1ad02e27c3a7eb59c1d696eb74cf246e94c0 call \
 container \
 with-inventory-file --inventory file:path
func (m *MyModule) Example(inventory *dagger.File) *dagger.AnsibleContainer  {
	return dag.
			Ansible().
			Container().
			WithInventoryFile(inventory)
}
@function
def example(inventory: dagger.File) -> dagger.AnsibleContainer:
	return (
		dag.ansible()
		.container()
		.with_inventory_file(inventory)
	)
@func()
example(inventory: File): AnsibleContainer {
	return dag
		.ansible()
		.container()
		.withInventoryFile(inventory)
}

withPlaybook() 🔗

WithPlaybook monte le playbook Ansible et le répertoire de projet Cette fonction est chainable et retourne un nouveau container

Exemple:

dagger call container ... \
  with-playbook --playbook ./playbook.yml --project ./ANSIBLE-TEMPLATES
Return Type
Container !
Arguments
NameTypeDefault ValueDescription
playbookFile !-Fichier playbook Ansible
projectDirectory !-Répertoire du projet contenant les rôles et fichiers Ansible
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/iac/ansible@35bf1ad02e27c3a7eb59c1d696eb74cf246e94c0 call \
 container \
 with-playbook --playbook file:path --project DIR_PATH
func (m *MyModule) Example(playbook *dagger.File, project *dagger.Directory) *dagger.AnsibleContainer  {
	return dag.
			Ansible().
			Container().
			WithPlaybook(playbook, project)
}
@function
def example(playbook: dagger.File, project: dagger.Directory) -> dagger.AnsibleContainer:
	return (
		dag.ansible()
		.container()
		.with_playbook(playbook, project)
	)
@func()
example(playbook: File, project: Directory): AnsibleContainer {
	return dag
		.ansible()
		.container()
		.withPlaybook(playbook, project)
}

withExtraVars() 🔗

WithExtraVars ajoute des variables supplémentaires pour Ansible Cette fonction est chainable et retourne un nouveau container

Exemple:

dagger call container ... \
  with-extra-vars --key install_golang --value "true" \
  with-extra-vars --key install_nodejs --value "true"
Return Type
Container !
Arguments
NameTypeDefault ValueDescription
keyString !-Nom de la variable
valueString !-Valeur de la variable
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/iac/ansible@35bf1ad02e27c3a7eb59c1d696eb74cf246e94c0 call \
 container \
 with-extra-vars --key string --value string
func (m *MyModule) Example(key string, value string) *dagger.AnsibleContainer  {
	return dag.
			Ansible().
			Container().
			WithExtraVars(key, value)
}
@function
def example(key: str, value: str) -> dagger.AnsibleContainer:
	return (
		dag.ansible()
		.container()
		.with_extra_vars(key, value)
	)
@func()
example(key: string, value: string): AnsibleContainer {
	return dag
		.ansible()
		.container()
		.withExtraVars(key, value)
}

withTags() 🔗

WithTags spécifie les tags Ansible à exécuter Cette fonction est chainable et retourne un nouveau container

Exemple:

dagger call container ... \
  with-tags --tags "setup,configure"
Return Type
Container !
Arguments
NameTypeDefault ValueDescription
tagsString !-Tags Ansible à exécuter (séparés par des virgules)
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/iac/ansible@35bf1ad02e27c3a7eb59c1d696eb74cf246e94c0 call \
 container \
 with-tags --tags string
func (m *MyModule) Example(tags string) *dagger.AnsibleContainer  {
	return dag.
			Ansible().
			Container().
			WithTags(tags)
}
@function
def example(tags: str) -> dagger.AnsibleContainer:
	return (
		dag.ansible()
		.container()
		.with_tags(tags)
	)
@func()
example(tags: string): AnsibleContainer {
	return dag
		.ansible()
		.container()
		.withTags(tags)
}

withSkipTags() 🔗

WithSkipTags spécifie les tags Ansible à ignorer Cette fonction est chainable et retourne un nouveau container

Exemple:

dagger call container ... \
  with-skip-tags --skip-tags "tests,validation"
Return Type
Container !
Arguments
NameTypeDefault ValueDescription
skipTagsString !-Tags Ansible à ignorer (séparés par des virgules)
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/iac/ansible@35bf1ad02e27c3a7eb59c1d696eb74cf246e94c0 call \
 container \
 with-skip-tags --skip-tags string
func (m *MyModule) Example(skipTags string) *dagger.AnsibleContainer  {
	return dag.
			Ansible().
			Container().
			WithSkipTags(skipTags)
}
@function
def example(skip_tags: str) -> dagger.AnsibleContainer:
	return (
		dag.ansible()
		.container()
		.with_skip_tags(skip_tags)
	)
@func()
example(skipTags: string): AnsibleContainer {
	return dag
		.ansible()
		.container()
		.withSkipTags(skipTags)
}

run() 🔗

Run exécute le playbook Ansible avec toute la configuration Cette fonction termine le chaînage et retourne la sortie de l’exécution

Exemple:

dagger call container ... with-playbook ... run
Return Type
String !
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/iac/ansible@35bf1ad02e27c3a7eb59c1d696eb74cf246e94c0 call \
 container \
 run
func (m *MyModule) Example(ctx context.Context) string  {
	return dag.
			Ansible().
			Container().
			Run(ctx)
}
@function
async def example() -> str:
	return await (
		dag.ansible()
		.container()
		.run()
	)
@func()
async example(): Promise<string> {
	return dag
		.ansible()
		.container()
		.run()
}

terminal() 🔗

Terminal retourne un terminal interactif dans le conteneur Ansible Utile pour le débogage

Exemple:

dagger call container ... with-playbook ... terminal
Return Type
Container !
Example
dagger -m dev.azure.com/dordogne/DAGGER-TEMPLATES/_git/DAGGER-TEMPLATES/iac/ansible@35bf1ad02e27c3a7eb59c1d696eb74cf246e94c0 call \
 container \
 terminal
func (m *MyModule) Example() *dagger.Container  {
	return dag.
			Ansible().
			Container().
			Terminal()
}
@function
def example() -> dagger.Container:
	return (
		dag.ansible()
		.container()
		.terminal()
	)
@func()
example(): Container {
	return dag
		.ansible()
		.container()
		.terminal()
}