File: issue_766__get_with_context.yml

package info (click to toggle)
python-mitogen 0.3.36-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,708 kB
  • sloc: python: 24,457; sh: 198; makefile: 74; perl: 19; ansic: 18
file content (69 lines) | stat: -rw-r--r-- 2,595 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# https://github.com/mitogen-hq/mitogen/issues/766
---
- name: regression/issue_766__get_with_context.yml
  hosts: localhost
  # Gather facts to use *and* to trigger any "could not recover task_vars" error
  # https://github.com/mitogen-hq/mitogen/pull/1215#issuecomment-2596421111
  gather_facts: true
  vars:
    netconf_container_image: ghcr.io/mitogen-hq/sysrepo-netopeer2:latest
    netconf_container_name: sysrepo
    netconf_container_port: 8030
    # https://github.com/ansible-collections/ansible.netcommon/issues/698#issuecomment-2910082548
    ansible_network_import_modules: "{{ (ansible_version_major_minor is version('2.19', '==', strict=True))  | bool }}"

  tasks:
    - meta: end_play
      when:
        # Podman can be installed on macOS, but authenticating to gchr.io isn't
        # worth the trouble right now.
        # See also
        #   - issue_655__wait_for_connection_error.yml
        - ansible_facts.system == 'Darwin'

    - meta: end_play
      when:
        # A failure during the ansible.netcommon.netconf_get task, when run
        # with Ansible 4 (ansible-core 2.11) & associated collections.
        # ansible.module_utils.connection.ConnectionError: Method not found
        # https://github.com/mitogen-hq/mitogen/actions/runs/12854359099/job/35838635886
        - ansible_version_major_minor is version('2.11', '>=', strict=True)
        - ansible_version_major_minor is version('2.12', '<', strict=True)

    - block:
        - name: Start container
          command:
            cmd: >-
              podman run
              --name "{{ netconf_container_name }}"
              --detach
              --rm
              --publish "{{ netconf_container_port }}:830"
              "{{ netconf_container_image }}"
          changed_when: true

        - name: Wait for container
          # TODO robust condition. wait_for + search_regex? wait_for_connection?
          wait_for:
            timeout: 5

        - name: Get running configuration and state data
          vars:
            ansible_connection: netconf
            ansible_user: netconf
            ansible_password: netconf
            ansible_port: "{{ netconf_container_port }}"
            ansible_host_key_checking: false
            ansible_python_interpreter: "{{ ansible_playbook_python }}"
          ansible.netcommon.netconf_get:

      always:
        - name: Close connections
          meta: reset_connection

        - name: Cleanup container
          command:
            cmd: podman stop "{{ netconf_container_name }}"
          changed_when: true
  tags:
    - issue_766