tech:ansible_docker_execution_environment
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| tech:ansible_docker_execution_environment [2025/09/24 16:26] – Jean-Baptiste | tech:ansible_docker_execution_environment [2026/06/16 15:19] (Version actuelle) – Jean-Baptiste | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| + | < | ||
| + | {{tag> | ||
| + | |||
| + | # Ansible Docker Execution Environment | ||
| + | |||
| + | Voir : | ||
| + | * [[notes_ansible_ansible-navigator|ansible-navigator]] | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * [|How to create execution environments using ansible-builder](https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | |||
| + | Voir aussi les execution-environment.yml : | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | ## Installation | ||
| + | |||
| + | ~~~bash | ||
| + | pip install --user ansible-builder> | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ## Utilisation | ||
| + | |||
| + | Fichiers : | ||
| + | * execution-environment.yml | ||
| + | * ansible.cfg | ||
| + | * requirements.txt | ||
| + | * requirements.yml | ||
| + | * bindep.txt | ||
| + | |||
| + | |||
| + | ~~~bash | ||
| + | podman login --tls-verify=false registry.acme.fr -u admin | ||
| + | # podman login --tls-verify=false registry.acme.fr -u admin -p P@ssw0rd | ||
| + | |||
| + | # Créer le dossier context/ avec le Containerfile | ||
| + | ansible-builder create #--file execution-environment-dev.yml | ||
| + | |||
| + | # Créer l' | ||
| + | podman build -f context/ | ||
| + | |||
| + | # Ou pour générer directement l' | ||
| + | ansible-builder build --tag img01:0.9.1 | ||
| + | |||
| + | podman images | ||
| + | podman image prune | ||
| + | |||
| + | podman tag localhost/ | ||
| + | podman images | ||
| + | podman push aahub.acme.local/ | ||
| + | ansible-navigator images --eei aahub.acme.local/ | ||
| + | |||
| + | ~~~ | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | ~~~bash | ||
| + | cd ansible-2.3_rhel5-repo/ | ||
| + | |||
| + | |||
| + | vim context/ | ||
| + | vim requirements.txt | ||
| + | vim requirements.yml | ||
| + | vim bindep.txt | ||
| + | vim execution-environment.yml | ||
| + | |||
| + | ansible-builder build -v 3 --tag img-rhel5_0.1 | ||
| + | podman build -f context/ | ||
| + | |||
| + | pip3 download psutils | ||
| + | |||
| + | podman push --tls-verify=false twr00210f.acme.local/ | ||
| + | |||
| + | ansible-navigator --eei twr00210f.acme.local/ | ||
| + | ansible-navigator --eei twr00210f.acme.local/ | ||
| + | ansible-navigator --eei twr00210f.acme.local/ | ||
| + | export ANSIBLE_NAVIGATOR_PULL_ARGUMENT=" | ||
| + | |||
| + | vim / | ||
| + | |||
| + | ansible-navigator -m stdout run reboot_idrac.yml -i inv.yml --eei twr00210f.acme.local/ | ||
| + | |||
| + | ansible-builder introspect --help | ||
| + | podman build -f context/ | ||
| + | ~~~ | ||
| + | |||
| + | ~~~bash | ||
| + | mkdir plop | ||
| + | cd plop | ||
| + | ~~~ | ||
| + | |||
| + | Nettoyage | ||
| + | ~~~bash | ||
| + | podman image prune | ||
| + | podman rmi < | ||
| + | rm -rf ./context/ | ||
| + | ~~~ | ||
| + | |||
| + | `ansible.cfg` | ||
| + | ~~~ini | ||
| + | # Since Ansible 2.12 (core): | ||
| + | # To generate an example config file (a " | ||
| + | # $ ansible-config init --disabled > ansible.cfg | ||
| + | # | ||
| + | # Also you can now have a more complete file by including existing plugins: | ||
| + | # ansible-config init --disabled -t all > ansible.cfg | ||
| + | |||
| + | # For previous versions of Ansible you can check for examples in the ' | ||
| + | # Note that this file was always incomplete | ||
| + | |||
| + | # for example, for 2.9: https:// | ||
| + | [galaxy] | ||
| + | server_list = rh-certified_repo, | ||
| + | |||
| + | [galaxy_server.rh-certified_repo] | ||
| + | token=xxxxxxxxxxxxxx1 | ||
| + | url=https:// | ||
| + | |||
| + | [galaxy_server.published_repo] | ||
| + | token=xxxxxxxxxxxxxx2 | ||
| + | url=https:// | ||
| + | |||
| + | [galaxy_server.community_repo] | ||
| + | token=xxxxxxxxxxxxxx3 | ||
| + | url=https:// | ||
| + | |||
| + | [galaxy_server.galaxy] | ||
| + | url=https:// | ||
| + | ~~~ | ||
| + | |||
| + | `bindep.txt` | ||
| + | ~~~ | ||
| + | python3-jmespath | ||
| + | ~~~ | ||
| + | |||
| + | `requirements.yml` | ||
| + | ~~~yaml | ||
| + | --- | ||
| + | collections: | ||
| + | - ansible.windows | ||
| + | - community.general | ||
| + | - ansible.posix | ||
| + | - awx.awx | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | `requirements.txt` | ||
| + | ~~~ | ||
| + | hvac | ||
| + | kafka-python | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | `execution-environment.yml` | ||
| + | ~~~yaml | ||
| + | --- | ||
| + | version: 1 | ||
| + | |||
| + | build_arg_defaults: | ||
| + | ANSIBLE_GALAXY_CLI_COLLECTION_OPTS: | ||
| + | EE_BASE_IMAGE: | ||
| + | EE_BUILDER_IMAGE: | ||
| + | |||
| + | ansible_config: | ||
| + | |||
| + | dependencies: | ||
| + | python: requirements.txt | ||
| + | galaxy: requirements.yml | ||
| + | system: bindep.txt | ||
| + | |||
| + | additional_build_steps: | ||
| + | prepend: | ||
| + | - RUN pip3 install --upgrade pip setuptools && echo " | ||
| + | - COPY ./cert.crt ~/ca | ||
| + | - RUN rpm --import https:// | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | `context/ | ||
| + | ~~~bash | ||
| + | ARG EE_BASE_IMAGE=aahub.acme.local/ | ||
| + | ARG EE_BUILDER_IMAGE=aahub.acme.local/ | ||
| + | |||
| + | FROM $EE_BASE_IMAGE as galaxy | ||
| + | ARG ANSIBLE_GALAXY_CLI_COLLECTION_OPTS=-c | ||
| + | USER root | ||
| + | |||
| + | ADD _build/ | ||
| + | |||
| + | ADD _build /build | ||
| + | WORKDIR /build | ||
| + | |||
| + | RUN ansible-galaxy role install -r requirements.yml --roles-path "/ | ||
| + | RUN ANSIBLE_GALAXY_DISABLE_GPG_VERIFY=1 ansible-galaxy collection install $ANSIBLE_GALAXY_CLI_COLLECTION_OPTS -r requirements.yml --collections-path "/ | ||
| + | |||
| + | FROM $EE_BUILDER_IMAGE as builder | ||
| + | |||
| + | COPY --from=galaxy / | ||
| + | |||
| + | ADD _build/ | ||
| + | RUN ansible-builder introspect --sanitize --user-pip=requirements.txt --write-bindep=/ | ||
| + | RUN assemble | ||
| + | |||
| + | FROM $EE_BASE_IMAGE | ||
| + | USER root | ||
| + | RUN pip3 install --upgrade pip setuptools && echo " | ||
| + | COPY ./cert.crt ~/ca | ||
| + | RUN rpm --import https:// | ||
| + | |||
| + | COPY --from=galaxy / | ||
| + | |||
| + | COPY --from=builder /output/ /output/ | ||
| + | RUN / | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ~~~yaml | ||
| + | version: 3 | ||
| + | |||
| + | dependencies: | ||
| + | galaxy: requirements.yml | ||
| + | python: requirements.txt | ||
| + | system: bindep.txt | ||
| + | |||
| + | # ansible_core: | ||
| + | # package_pip: | ||
| + | # | ||
| + | # ansible_runner: | ||
| + | # package_pip: | ||
| + | # | ||
| + | # python_interpreter: | ||
| + | # package_system: | ||
| + | # python_path: | ||
| + | |||
| + | exclude: | ||
| + | python: | ||
| + | - docker | ||
| + | system: | ||
| + | - python3-Cython | ||
| + | |||
| + | images: | ||
| + | base_image: | ||
| + | # name: quay.io/ | ||
| + | # name: quay.io/ | ||
| + | # name: ghcr.io/ | ||
| + | # name: quay.io/ | ||
| + | name: ghcr.io/ | ||
| + | |||
| + | # additional_build_files: | ||
| + | # - src: files/ | ||
| + | # dest: configs | ||
| + | |||
| + | additional_build_steps: | ||
| + | # prepend_galaxy: | ||
| + | # - ADD _build/ | ||
| + | prepend_base: | ||
| + | # - RUN echo PLOP | ||
| + | append_final: | ||
| + | # - RUN groupadd --gid 1000 vscode | ||
| + | # - RUN adduser --home-dir /vscode --create-home --gid 1000 --uid 1000 vscode | ||
| + | - RUN ls -l | ||
| + | |||
| + | options: | ||
| + | user: ' | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ------------ | ||
| + | |||
| + | `execution-environment.yml` | ||
| + | ~~~yaml | ||
| + | --- | ||
| + | |||
| + | version: 3 | ||
| + | |||
| + | dependencies: | ||
| + | galaxy: requirements.yml | ||
| + | python: requirements.txt | ||
| + | system: bindep.txt | ||
| + | |||
| + | images: | ||
| + | base_image: | ||
| + | name: ghcr.io/ | ||
| + | |||
| + | options: | ||
| + | user: ' | ||
| + | ~~~ | ||
| + | |||
| + | `requirements.yml` | ||
| + | ~~~yaml | ||
| + | --- | ||
| + | |||
| + | collections: | ||
| + | - ansible.utils | ||
| + | - ansible.posix | ||
| + | - ansible.windows | ||
| + | - ansible.netcommon | ||
| + | - community.general | ||
| + | - community.windows | ||
| + | - community.vmware | ||
| + | - community.crypto | ||
| + | - community.postgresql | ||
| + | - community.mysql | ||
| + | - community.network | ||
| + | - kubernetes.core | ||
| + | - containers.podman | ||
| + | - awx.awx | ||
| + | - vmware.vmware | ||
| + | - vmware.vmware_rest | ||
| + | - microsoft.ad | ||
| + | # - fortinet.fortios | ||
| + | ~~~ | ||
| + | |||
| + | `requirements.txt` | ||
| + | ~~~ | ||
| + | six | ||
| + | psutil | ||
| + | # pywinrm | ||
| + | jc | ||
| + | jmespath | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | `bindep.txt` | ||
| + | ~~~ | ||
| + | git | ||
| + | rsync | ||
| + | curl | ||
| + | wget | ||
| + | psmisc | ||
| + | tar | ||
| + | unzip | ||
| + | gzip | ||
| + | # | ||
| + | iputils [platform: | ||
| + | bind-utils [platform: | ||
| + | # | ||
| + | # | ||
| + | ~~~ | ||
| + | |||
| + | Exemple de fichier bindep.txt : | ||
| + | * https:// | ||
| + | |||
| + | |||
| + | |||
