| 1 |
--- |
| 2 |
|
| 3 |
# These tests are likely slower than they should be, since each |
| 4 |
# invocation of apt_repository seems to end up querying for |
| 5 |
# lots (all?) configured repos. |
| 6 |
|
| 7 |
- set_fact: |
| 8 |
test_repo_spec: "deb http://apt.postgresql.org/pub/repos/apt/ {{ ansible_distribution_release }}-pgdg main" |
| 9 |
test_repo_path: /etc/apt/sources.list.d/apt_postgresql_org_pub_repos_apt.list |
| 10 |
|
| 11 |
- import_tasks: mode_cleanup.yaml |
| 12 |
|
| 13 |
- name: Add GPG key to verify signatures |
| 14 |
apt_key: |
| 15 |
id: 7FCC7D46ACCC4CF8 |
| 16 |
keyserver: keyserver.ubuntu.com |
| 17 |
|
| 18 |
- name: Mode specified as yaml literal 0600 |
| 19 |
apt_repository: |
| 20 |
repo: "{{ test_repo_spec }}" |
| 21 |
state: present |
| 22 |
mode: 0600 |
| 23 |
update_cache: false |
| 24 |
register: mode_given_results |
| 25 |
|
| 26 |
- name: Gather mode_given_as_literal_yaml stat |
| 27 |
stat: |
| 28 |
path: "{{ test_repo_path }}" |
| 29 |
register: mode_given_yaml_literal_0600 |
| 30 |
|
| 31 |
- name: Show mode_given_yaml_literal_0600 |
| 32 |
debug: |
| 33 |
var: mode_given_yaml_literal_0600 |
| 34 |
|
| 35 |
- import_tasks: mode_cleanup.yaml |
| 36 |
|
| 37 |
- name: Assert mode_given_yaml_literal_0600 is correct |
| 38 |
assert: |
| 39 |
that: "mode_given_yaml_literal_0600.stat.mode == '0600'" |
| 40 |
|
| 41 |
- name: No mode specified |
| 42 |
apt_repository: |
| 43 |
repo: "{{ test_repo_spec }}" |
| 44 |
state: present |
| 45 |
update_cache: false |
| 46 |
register: no_mode_results |
| 47 |
|
| 48 |
- name: Gather no mode stat |
| 49 |
stat: |
| 50 |
path: "{{ test_repo_path }}" |
| 51 |
register: no_mode_stat |
| 52 |
|
| 53 |
- name: Show no mode stat |
| 54 |
debug: |
| 55 |
var: no_mode_stat |
| 56 |
|
| 57 |
- import_tasks: mode_cleanup.yaml |
| 58 |
|
| 59 |
- name: Assert no_mode_stat is correct |
| 60 |
assert: |
| 61 |
that: "no_mode_stat.stat.mode == '0644'" |
| 62 |
|
| 63 |
- name: Mode specified as string 0600 |
| 64 |
apt_repository: |
| 65 |
repo: "{{ test_repo_spec }}" |
| 66 |
state: present |
| 67 |
mode: "0600" |
| 68 |
update_cache: false |
| 69 |
register: mode_given_string_results |
| 70 |
|
| 71 |
- name: Gather mode_given_string stat |
| 72 |
stat: |
| 73 |
path: "{{ test_repo_path }}" |
| 74 |
register: mode_given_string_stat |
| 75 |
|
| 76 |
- name: Show mode_given_string_stat |
| 77 |
debug: |
| 78 |
var: mode_given_string_stat |
| 79 |
|
| 80 |
- import_tasks: mode_cleanup.yaml |
| 81 |
|
| 82 |
- name: Mode specified as string 600 |
| 83 |
apt_repository: |
| 84 |
repo: "{{ test_repo_spec }}" |
| 85 |
state: present |
| 86 |
mode: "600" |
| 87 |
update_cache: false |
| 88 |
register: mode_given_string_600_results |
| 89 |
|
| 90 |
- name: Gather mode_given_600_string stat |
| 91 |
stat: |
| 92 |
path: "{{ test_repo_path }}" |
| 93 |
register: mode_given_string_600_stat |
| 94 |
|
| 95 |
- name: Show mode_given_string_stat |
| 96 |
debug: |
| 97 |
var: mode_given_string_600_stat |
| 98 |
|
| 99 |
- import_tasks: mode_cleanup.yaml |
| 100 |
|
| 101 |
- name: Assert mode is correct |
| 102 |
assert: |
| 103 |
that: "mode_given_string_600_stat.stat.mode == '0600'" |
| 104 |
|
| 105 |
- name: Mode specified as yaml literal 600 |
| 106 |
apt_repository: |
| 107 |
repo: "{{ test_repo_spec }}" |
| 108 |
state: present |
| 109 |
mode: 600 |
| 110 |
update_cache: false |
| 111 |
register: mode_given_short_results |
| 112 |
|
| 113 |
- name: Gather mode_given_yaml_literal_600 stat |
| 114 |
stat: |
| 115 |
path: "{{ test_repo_path }}" |
| 116 |
register: mode_given_yaml_literal_600 |
| 117 |
|
| 118 |
- name: Show mode_given_yaml_literal_600 |
| 119 |
debug: |
| 120 |
var: mode_given_yaml_literal_600 |
| 121 |
|
| 122 |
- import_tasks: mode_cleanup.yaml |
| 123 |
|
| 124 |
# a literal 600 as the mode will fail currently, in the sense that it |
| 125 |
# doesn't guess and consider 600 and 0600 to be the same, and will instead |
| 126 |
# interpret literal 600 as the decimal 600 (and thereby octal 1130). |
| 127 |
# The literal 0600 can be interpreted as octal correctly. Note that |
| 128 |
# a decimal 644 is octal 420. The default perm is 0644 so a misinterpretation |
| 129 |
# of 644 was previously resulting in a default file mode of 0420. |
| 130 |
# 'mode: 600' is likely not what a user meant but there isn't enough info |
| 131 |
# to determine that. Note that a string arg of '600' will be interpreted as 0600. |
| 132 |
# See https://github.com/ansible/ansible/issues/16370 |
| 133 |
- name: Assert mode_given_yaml_literal_600 is correct |
| 134 |
assert: |
| 135 |
that: "mode_given_yaml_literal_600.stat.mode == '1130'" |