1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
- name: Remove container ignore_errors: yes run_once: yes delegate_to: localhost community.docker.docker_container: name: "my-container" force_kill: yes state: absent- name: Create build container run_once: yes delegate_to: localhost community.docker.docker_container: image: debian:12 name: "my-container" command: sleep 1d auto_remove: true register: container- name: Add container to inventory run_once: yes delegate_to: localhost add_host: name: my-container ansible_connection: docker changed_when: false- name: Prepare run_once: yes delegate_to: my-container vars: ansible_ssh_user: root block: - name: Bootstrap docker ansible.builtin.raw: apt update && apt install -yqq python3 - name: Get facts setup: delegate_facts: true- name: Do job run_once: yes delegate_to: my-container vars: ansible_ssh_user: root block: - name: install htop ansible.builtin.apt: name: htop update_cache: yes- name: Remove container run_once: yes delegate_to: localhost community.docker.docker_container: name: my-container force_kill: yes state: absent