"Fossies" - the Fresh Open Source Software Archive

Member "ansible-6.1.0/ansible_collections/community/general/tests/integration/targets/dpkg_divert/tasks/tests/01-basic.yml" (12 Jul 2022, 7580 Bytes) of package /linux/misc/ansible-6.1.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Ansible YAML source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 ---
    2 ################################################################################
    3 # TEST 01: state=present
    4 
    5 - name: "create foobarrc for tests"
    6   copy:
    7     dest: "{{ foobarrc }}"
    8     content: "{{ foobarrc_oldtext }}"
    9 
   10 
   11 - name: "divert foobarrc (check mode, must report a change)"
   12   dpkg_divert:
   13     path: "{{ foobarrc }}"
   14     state: present
   15   register: diversion_0
   16   check_mode: true
   17 
   18 - name: "divert foobarrc (must report a change)"
   19   dpkg_divert:
   20     path: "{{ foobarrc }}"
   21     state: present
   22   register: diversion_1
   23 
   24 
   25 - name: "divert foobarrc (must NOT report a change, idempotency)"
   26   dpkg_divert:
   27     path: "{{ foobarrc }}"
   28     state: present
   29   register: diversion_2
   30 
   31 - name: "divert foobarrc (check mode, must NOT report a change, idempotency)"
   32   dpkg_divert:
   33     path: "{{ foobarrc }}"
   34     state: present
   35   register: diversion_3
   36   check_mode: true
   37 
   38 
   39 # Ensure that 'rename' has no effect when state is not changed
   40 
   41 - name: "divert foobarrc (rename, must NOT report a change, idempotency)"
   42   dpkg_divert:
   43     path: "{{ foobarrc }}"
   44     state: present
   45     rename: yes
   46   register: diversion_4
   47 
   48 - name: "divert foobarrc (check mode, rename, must NOT report a change, idempotency)"
   49   dpkg_divert:
   50     path: "{{ foobarrc }}"
   51     state: present
   52     rename: yes
   53   register: diversion_5
   54   check_mode: true
   55 
   56 
   57 # Check results
   58 
   59 - name: "stat foobarrc (must still be there)"
   60   stat:
   61     path: "{{ foobarrc }}"
   62   register: diversion_6
   63 
   64 - name: "stat foobarrc.distrib (must not exist)"
   65   stat:
   66     path: "{{ foobarrc_distrib }}"
   67   register: diversion_7
   68 
   69 - name: "assert that results of test 01 are as expected"
   70   assert:
   71     that:
   72       - diversion_0 is changed
   73       - diversion_1 is changed
   74       - diversion_2 is not changed
   75       - diversion_3 is not changed
   76       - diversion_4 is not changed
   77       - diversion_5 is not changed
   78       - diversion_6.stat.exists
   79       - diversion_6.stat.checksum == foobarrc_oldsha1
   80       - not diversion_7.stat.exists
   81       - diversion_0.diversion == diversion_1.diversion
   82       - diversion_2.diversion == diversion_3.diversion
   83       - diversion_4.diversion == diversion_5.diversion
   84       - diversion_0.commands == diversion_1.commands
   85       - diversion_2.commands == diversion_3.commands
   86       - diversion_4.commands == diversion_5.commands
   87     quiet: yes
   88 
   89 
   90 ################################################################################
   91 # TEST 02: state=absent
   92 
   93 - name: "remove diversion for foobarrc (check mode, must report a change)"
   94   dpkg_divert:
   95     path: "{{ foobarrc }}"
   96     state: absent
   97   register: diversion_0
   98   check_mode: true
   99 
  100 - name: "remove diversion for foobarrc (must report a change)"
  101   dpkg_divert:
  102     path: "{{ foobarrc }}"
  103     state: absent
  104   register: diversion_1
  105 
  106 
  107 - name: "remove diversion for foobarrc (must NOT report a change, idempotency)"
  108   dpkg_divert:
  109     path: "{{ foobarrc }}"
  110     state: absent
  111   register: diversion_2
  112 
  113 - name: "remove diversion for foobarrc (check mode, must NOT report a change, idempotency)"
  114   dpkg_divert:
  115     path: "{{ foobarrc }}"
  116     state: absent
  117   register: diversion_3
  118   check_mode: true
  119 
  120 
  121 # Check results
  122 
  123 - name: "stat foobarrc (must still be there)"
  124   stat:
  125     path: "{{ foobarrc }}"
  126   register: diversion_4
  127 
  128 - name: "stat foobarrc.distrib (must not exist)"
  129   stat:
  130     path: "{{ foobarrc_distrib }}"
  131   register: diversion_5
  132 
  133 - name: "assert that results of test 02 are as expected"
  134   assert:
  135     that:
  136       - diversion_0 is changed
  137       - diversion_1 is changed
  138       - diversion_2 is not changed
  139       - diversion_3 is not changed
  140       - diversion_4.stat.exists
  141       - diversion_4.stat.checksum == foobarrc_oldsha1
  142       - not diversion_5.stat.exists
  143       - diversion_0.diversion == diversion_1.diversion
  144       - diversion_2.diversion == diversion_3.diversion
  145       - diversion_0.commands == diversion_1.commands
  146       - diversion_2.commands == diversion_3.commands
  147     quiet: yes
  148 
  149 
  150 ################################################################################
  151 # TEST 03: holder=ansible
  152 
  153 - name: "create foobarrc diversion with defaults"
  154   dpkg_divert:
  155     path: "{{ foobarrc }}"
  156 
  157 
  158 - name: "update foobarrc diversion holder (check mode, must report a change)"
  159   dpkg_divert:
  160     path: "{{ foobarrc }}"
  161     holder: "ansible"
  162   register: diversion_0
  163   check_mode: yes
  164 
  165 - name: "update foobarrc diversion holder (must report a change)"
  166   dpkg_divert:
  167     path: "{{ foobarrc }}"
  168     holder: "ansible"
  169   register: diversion_1
  170 
  171 
  172 - name: "update foobarrc diversion holder (must NOT report a change, idempotency)"
  173   dpkg_divert:
  174     path: "{{ foobarrc }}"
  175     holder: "ansible"
  176   register: diversion_2
  177 
  178 - name: "update foobarrc diversion holder (check mode, must NOT report a change, idempotency)"
  179   dpkg_divert:
  180     path: "{{ foobarrc }}"
  181     holder: "ansible"
  182   register: diversion_3
  183   check_mode: yes
  184 
  185 
  186 # Check results
  187 
  188 - name: "stat foobarrc (must still be there)"
  189   stat:
  190     path: "{{ foobarrc }}"
  191   register: diversion_4
  192 
  193 - name: "stat foobarrc.distrib (must not exist)"
  194   stat:
  195     path: "{{ foobarrc_distrib }}"
  196   register: diversion_5
  197 
  198 - name: "assert that results of test 03 are as expected"
  199   assert:
  200     that:
  201       - diversion_0 is changed
  202       - diversion_1 is changed
  203       - diversion_2 is not changed
  204       - diversion_3 is not changed
  205       - diversion_4.stat.exists
  206       - diversion_4.stat.checksum == foobarrc_oldsha1
  207       - not diversion_5.stat.exists
  208       - diversion_0.diversion == diversion_1.diversion
  209       - diversion_2.diversion == diversion_3.diversion
  210       - diversion_0.commands == diversion_1.commands
  211       - diversion_2.commands == diversion_3.commands
  212     quiet: yes
  213 
  214 - name: "remove foobarrc diversion"
  215   dpkg_divert:
  216     path: "{{ foobarrc }}"
  217     state: absent
  218 
  219 
  220 ################################################################################
  221 # TEST 04: divert=/etc/foobarrc.ansible
  222 
  223 - name: "create foobarrc diversion with defaults"
  224   dpkg_divert:
  225     path: "{{ foobarrc }}"
  226 
  227 
  228 - name: "update foobarrc divert path (check mode, must report a change)"
  229   dpkg_divert:
  230     path: "{{ foobarrc }}"
  231     divert: "{{ foobarrc_ansible }}"
  232   register: diversion_0
  233   check_mode: yes
  234 
  235 - name: "update foobarrc divert path (must report a change)"
  236   dpkg_divert:
  237     path: "{{ foobarrc }}"
  238     divert: "{{ foobarrc_ansible }}"
  239   register: diversion_1
  240 
  241 
  242 - name: "update foobarrc divert path (must NOT report a change, idempotency)"
  243   dpkg_divert:
  244     path: "{{ foobarrc }}"
  245     divert: "{{ foobarrc_ansible }}"
  246   register: diversion_2
  247 
  248 - name: "update foobarrc divert path (check mode, must NOT report a change, idempotency)"
  249   dpkg_divert:
  250     path: "{{ foobarrc }}"
  251     divert: "{{ foobarrc_ansible }}"
  252   register: diversion_3
  253   check_mode: yes
  254 
  255 
  256 # Check results
  257 
  258 - name: "stat foobarrc (must still be there)"
  259   stat:
  260     path: "{{ foobarrc }}"
  261   register: diversion_4
  262 
  263 - name: "stat foobarrc.ansible (must not exist)"
  264   stat:
  265     path: "{{ foobarrc_ansible }}"
  266   register: diversion_5
  267 
  268 - name: "assert that results of test 04 are as expected"
  269   assert:
  270     that:
  271       - diversion_0 is changed
  272       - diversion_1 is changed
  273       - diversion_2 is not changed
  274       - diversion_3 is not changed
  275       - diversion_4.stat.exists
  276       - diversion_4.stat.checksum == foobarrc_oldsha1
  277       - not diversion_5.stat.exists
  278       - diversion_0.diversion == diversion_1.diversion
  279       - diversion_2.diversion == diversion_3.diversion
  280       - diversion_0.commands == diversion_1.commands
  281       - diversion_2.commands == diversion_3.commands
  282     quiet: yes
  283 
  284 - name: "remove foobarrc diversion"
  285   dpkg_divert:
  286     path: "{{ foobarrc }}"
  287     state: absent