Skip to content

Commit 347f864

Browse files
authored
Ansible upgrade 6.1 (#14500)
* linting * update ansible * linters
1 parent a43de09 commit 347f864

File tree

59 files changed

+1157
-1156
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1157
-1156
lines changed

.ansible-lint

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
skip_list:
2+
- yaml
23
- '204'
34
verbosity: 1
45

56
warn_list:
67
- no-changed-when
8+
- no-handler
9+
- fqcn-builtins
10+
- var-spacing

.github/workflows/main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
python -m pip install --upgrade pip
1919
pip install -r requirements.txt
2020
sudo snap install shellcheck
21-
pip install ansible-lint
21+
pip install ansible-lint==6.3.0
2222
2323
- name: Checks and linters
2424
run: |

cloud.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88

99
tasks:
1010
- block:
11-
- name: Local pre-tasks
12-
import_tasks: playbooks/cloud-pre.yml
11+
- name: Local pre-tasks
12+
import_tasks: playbooks/cloud-pre.yml
1313

14-
- name: Include a provisioning role
15-
include_role:
16-
name: "{{ 'local' if algo_provider == 'local' else 'cloud-' + algo_provider }}"
14+
- name: Include a provisioning role
15+
include_role:
16+
name: "{{ 'local' if algo_provider == 'local' else 'cloud-' + algo_provider }}"
1717

18-
- name: Local post-tasks
19-
import_tasks: playbooks/cloud-post.yml
18+
- name: Local post-tasks
19+
import_tasks: playbooks/cloud-post.yml
2020
rescue:
2121
- include_tasks: playbooks/rescue.yml

deploy_client.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
ansible_ssh_user: "{{ 'root' if client_ip == 'localhost' else ssh_user }}"
1414
vpn_user: "{{ vpn_user }}"
1515
IP_subject_alt_name: "{{ server_ip }}"
16-
ansible_python_interpreter: "/usr/bin/python3"
16+
ansible_python_interpreter: /usr/bin/python3
1717

1818
- name: Configure the client and install required software
1919
hosts: client-host

input.yml

+103-104
Original file line numberDiff line numberDiff line change
@@ -18,127 +18,126 @@
1818
- { name: Google Compute Engine, alias: gce }
1919
- { name: Hetzner Cloud, alias: hetzner }
2020
- { name: Vultr, alias: vultr }
21-
- { name: Scaleway, alias: scaleway}
21+
- { name: Scaleway, alias: scaleway }
2222
- { name: OpenStack (DreamCompute optimised), alias: openstack }
2323
- { name: CloudStack (Exoscale optimised), alias: cloudstack }
2424
- { name: Linode, alias: linode }
25-
- { name: "Install to existing Ubuntu 18.04 or 20.04 server (for more advanced users)", alias: local }
25+
- { name: Install to existing Ubuntu 18.04 or 20.04 server (for more advanced users), alias: local }
2626
vars_files:
2727
- config.cfg
2828

2929
tasks:
3030
- block:
31-
- name: Cloud prompt
32-
pause:
33-
prompt: |
34-
What provider would you like to use?
35-
{% for p in providers_map %}
36-
{{ loop.index }}. {{ p['name'] }}
37-
{% endfor %}
31+
- name: Cloud prompt
32+
pause:
33+
prompt: |
34+
What provider would you like to use?
35+
{% for p in providers_map %}
36+
{{ loop.index }}. {{ p['name'] }}
37+
{% endfor %}
3838
39-
Enter the number of your desired provider
40-
register: _algo_provider
41-
when: provider is undefined
39+
Enter the number of your desired provider
40+
register: _algo_provider
41+
when: provider is undefined
4242

43-
- name: Set facts based on the input
44-
set_fact:
45-
algo_provider: "{{ provider | default(providers_map[_algo_provider.user_input|default(omit)|int - 1]['alias']) }}"
43+
- name: Set facts based on the input
44+
set_fact:
45+
algo_provider: "{{ provider | default(providers_map[_algo_provider.user_input|default(omit)|int - 1]['alias']) }}"
4646

47-
- name: VPN server name prompt
48-
pause:
49-
prompt: |
50-
Name the vpn server
51-
[algo]
52-
register: _algo_server_name
53-
when:
54-
- server_name is undefined
55-
- algo_provider != "local"
47+
- name: VPN server name prompt
48+
pause:
49+
prompt: |
50+
Name the vpn server
51+
[algo]
52+
register: _algo_server_name
53+
when:
54+
- server_name is undefined
55+
- algo_provider != "local"
5656

57-
- name: Cellular On Demand prompt
58-
pause:
59-
prompt: |
60-
Do you want macOS/iOS clients to enable "Connect On Demand" when connected to cellular networks?
61-
[y/N]
62-
register: _ondemand_cellular
63-
when: ondemand_cellular is undefined
57+
- name: Cellular On Demand prompt
58+
pause:
59+
prompt: |
60+
Do you want macOS/iOS clients to enable "Connect On Demand" when connected to cellular networks?
61+
[y/N]
62+
register: _ondemand_cellular
63+
when: ondemand_cellular is undefined
6464

65-
- name: Wi-Fi On Demand prompt
66-
pause:
67-
prompt: |
68-
Do you want macOS/iOS clients to enable "Connect On Demand" when connected to Wi-Fi?
69-
[y/N]
70-
register: _ondemand_wifi
71-
when: ondemand_wifi is undefined
65+
- name: Wi-Fi On Demand prompt
66+
pause:
67+
prompt: |
68+
Do you want macOS/iOS clients to enable "Connect On Demand" when connected to Wi-Fi?
69+
[y/N]
70+
register: _ondemand_wifi
71+
when: ondemand_wifi is undefined
7272

73-
- name: Trusted Wi-Fi networks prompt
74-
pause:
75-
prompt: |
76-
List the names of any trusted Wi-Fi networks where macOS/iOS clients should not use "Connect On Demand"
77-
(e.g., your home network. Comma-separated value, e.g., HomeNet,OfficeWifi,AlgoWiFi)
78-
register: _ondemand_wifi_exclude
79-
when:
80-
- ondemand_wifi_exclude is undefined
81-
- (ondemand_wifi|default(false)|bool) or
82-
(booleans_map[_ondemand_wifi.user_input|default(omit)]|default(false))
73+
- name: Trusted Wi-Fi networks prompt
74+
pause:
75+
prompt: |
76+
List the names of any trusted Wi-Fi networks where macOS/iOS clients should not use "Connect On Demand"
77+
(e.g., your home network. Comma-separated value, e.g., HomeNet,OfficeWifi,AlgoWiFi)
78+
register: _ondemand_wifi_exclude
79+
when:
80+
- ondemand_wifi_exclude is undefined
81+
- (ondemand_wifi|default(false)|bool) or (booleans_map[_ondemand_wifi.user_input|default(omit)]|default(false))
8382

84-
- name: Retain the PKI prompt
85-
pause:
86-
prompt: |
87-
Do you want to retain the keys (PKI)? (required to add users in the future, but less secure)
88-
[y/N]
89-
register: _store_pki
90-
when:
91-
- store_pki is undefined
92-
- ipsec_enabled
83+
- name: Retain the PKI prompt
84+
pause:
85+
prompt: |
86+
Do you want to retain the keys (PKI)? (required to add users in the future, but less secure)
87+
[y/N]
88+
register: _store_pki
89+
when:
90+
- store_pki is undefined
91+
- ipsec_enabled
9392

94-
- name: DNS adblocking prompt
95-
pause:
96-
prompt: |
97-
Do you want to enable DNS ad blocking on this VPN server?
98-
[y/N]
99-
register: _dns_adblocking
100-
when: dns_adblocking is undefined
93+
- name: DNS adblocking prompt
94+
pause:
95+
prompt: |
96+
Do you want to enable DNS ad blocking on this VPN server?
97+
[y/N]
98+
register: _dns_adblocking
99+
when: dns_adblocking is undefined
101100

102-
- name: SSH tunneling prompt
103-
pause:
104-
prompt: |
105-
Do you want each user to have their own account for SSH tunneling?
106-
[y/N]
107-
register: _ssh_tunneling
108-
when: ssh_tunneling is undefined
101+
- name: SSH tunneling prompt
102+
pause:
103+
prompt: |
104+
Do you want each user to have their own account for SSH tunneling?
105+
[y/N]
106+
register: _ssh_tunneling
107+
when: ssh_tunneling is undefined
109108

110-
- name: Set facts based on the input
111-
set_fact:
112-
algo_server_name: >-
113-
{% if server_name is defined %}{% set _server = server_name %}
114-
{%- elif _algo_server_name.user_input is defined and _algo_server_name.user_input|length > 0 -%}
115-
{%- set _server = _algo_server_name.user_input -%}
116-
{%- else %}{% set _server = defaults['server_name'] %}{% endif -%}
117-
{{ _server | regex_replace('(?!\.)(\W|_)', '-') }}
118-
algo_ondemand_cellular: >-
119-
{% if ondemand_cellular is defined %}{{ ondemand_cellular | bool }}
120-
{%- elif _ondemand_cellular.user_input is defined %}{{ booleans_map[_ondemand_cellular.user_input] | default(defaults['ondemand_cellular']) }}
121-
{%- else %}false{% endif %}
122-
algo_ondemand_wifi: >-
123-
{% if ondemand_wifi is defined %}{{ ondemand_wifi | bool }}
124-
{%- elif _ondemand_wifi.user_input is defined %}{{ booleans_map[_ondemand_wifi.user_input] | default(defaults['ondemand_wifi']) }}
125-
{%- else %}false{% endif %}
126-
algo_ondemand_wifi_exclude: >-
127-
{% if ondemand_wifi_exclude is defined %}{{ ondemand_wifi_exclude | b64encode }}
128-
{%- elif _ondemand_wifi_exclude.user_input is defined and _ondemand_wifi_exclude.user_input|length > 0 -%}
129-
{{ _ondemand_wifi_exclude.user_input | b64encode }}
130-
{%- else %}{{ '_null' | b64encode }}{% endif %}
131-
algo_dns_adblocking: >-
132-
{% if dns_adblocking is defined %}{{ dns_adblocking | bool }}
133-
{%- elif _dns_adblocking.user_input is defined %}{{ booleans_map[_dns_adblocking.user_input] | default(defaults['dns_adblocking']) }}
134-
{%- else %}false{% endif %}
135-
algo_ssh_tunneling: >-
136-
{% if ssh_tunneling is defined %}{{ ssh_tunneling | bool }}
137-
{%- elif _ssh_tunneling.user_input is defined %}{{ booleans_map[_ssh_tunneling.user_input] | default(defaults['ssh_tunneling']) }}
138-
{%- else %}false{% endif %}
139-
algo_store_pki: >-
140-
{% if ipsec_enabled %}{%- if store_pki is defined %}{{ store_pki | bool }}
141-
{%- elif _store_pki.user_input is defined %}{{ booleans_map[_store_pki.user_input] | default(defaults['store_pki']) }}
142-
{%- else %}false{% endif %}{% endif %}
109+
- name: Set facts based on the input
110+
set_fact:
111+
algo_server_name: >-
112+
{% if server_name is defined %}{% set _server = server_name %}
113+
{%- elif _algo_server_name.user_input is defined and _algo_server_name.user_input|length > 0 -%}
114+
{%- set _server = _algo_server_name.user_input -%}
115+
{%- else %}{% set _server = defaults['server_name'] %}{% endif -%}
116+
{{ _server | regex_replace('(?!\.)(\W|_)', '-') }}
117+
algo_ondemand_cellular: >-
118+
{% if ondemand_cellular is defined %}{{ ondemand_cellular | bool }}
119+
{%- elif _ondemand_cellular.user_input is defined %}{{ booleans_map[_ondemand_cellular.user_input] | default(defaults['ondemand_cellular']) }}
120+
{%- else %}false{% endif %}
121+
algo_ondemand_wifi: >-
122+
{% if ondemand_wifi is defined %}{{ ondemand_wifi | bool }}
123+
{%- elif _ondemand_wifi.user_input is defined %}{{ booleans_map[_ondemand_wifi.user_input] | default(defaults['ondemand_wifi']) }}
124+
{%- else %}false{% endif %}
125+
algo_ondemand_wifi_exclude: >-
126+
{% if ondemand_wifi_exclude is defined %}{{ ondemand_wifi_exclude | b64encode }}
127+
{%- elif _ondemand_wifi_exclude.user_input is defined and _ondemand_wifi_exclude.user_input|length > 0 -%}
128+
{{ _ondemand_wifi_exclude.user_input | b64encode }}
129+
{%- else %}{{ '_null' | b64encode }}{% endif %}
130+
algo_dns_adblocking: >-
131+
{% if dns_adblocking is defined %}{{ dns_adblocking | bool }}
132+
{%- elif _dns_adblocking.user_input is defined %}{{ booleans_map[_dns_adblocking.user_input] | default(defaults['dns_adblocking']) }}
133+
{%- else %}false{% endif %}
134+
algo_ssh_tunneling: >-
135+
{% if ssh_tunneling is defined %}{{ ssh_tunneling | bool }}
136+
{%- elif _ssh_tunneling.user_input is defined %}{{ booleans_map[_ssh_tunneling.user_input] | default(defaults['ssh_tunneling']) }}
137+
{%- else %}false{% endif %}
138+
algo_store_pki: >-
139+
{% if ipsec_enabled %}{%- if store_pki is defined %}{{ store_pki | bool }}
140+
{%- elif _store_pki.user_input is defined %}{{ booleans_map[_store_pki.user_input] | default(defaults['store_pki']) }}
141+
{%- else %}false{% endif %}{% endif %}
143142
rescue:
144143
- include_tasks: playbooks/rescue.yml

main.yml

+9-6
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,15 @@
2323

2424
- name: Set required ansible version as a fact
2525
set_fact:
26-
required_ansible_version:
27-
"{{ item | regex_replace('^ansible-core[\\s+]?(?P<op>[=,>,<]+)[\\s+]?(?P<ver>\\d.\\d+(.\\d+)?)$',
28-
'{\"op\": \"\\g<op>\",\"ver\": \"\\g<ver>\" }') }}"
29-
when: '"ansible-core" in item'
26+
required_ansible_version: "{{ item | regex_replace('^ansible[\\s+]?(?P<op>[=,>,<]+)[\\s+]?(?P<ver>\\d.\\d+(.\\d+)?)$', '{\"op\": \"\\g<op>\",\"ver\"\
27+
: \"\\g<ver>\" }') }}"
28+
when: '"ansible" in item'
3029
with_items: "{{ lookup('file', 'requirements.txt').splitlines() }}"
3130

31+
- name: Just get the list from default pip
32+
community.general.pip_package_info:
33+
register: pip_package_info
34+
3235
- name: Verify Python meets Algo VPN requirements
3336
assert:
3437
that: (ansible_python.version.major|string + '.' + ansible_python.version.minor|string) is version('3.8', '>=')
@@ -40,10 +43,10 @@
4043
- name: Verify Ansible meets Algo VPN requirements
4144
assert:
4245
that:
43-
- ansible_version.full is version(required_ansible_version.ver, required_ansible_version.op)
46+
- pip_package_info.packages.pip.ansible.0.version is version(required_ansible_version.ver, required_ansible_version.op)
4447
- not ipaddr.failed
4548
msg: >
46-
Ansible version is {{ ansible_version.full }}.
49+
Ansible version is {{ pip_package_info.packages.pip.ansible.0.version }}.
4750
You must update the requirements to use this version of Algo.
4851
Try to run python3 -m pip install -U -r requirements.txt
4952

playbooks/cloud-post.yml

+3-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
ansible_connection: "{% if cloud_instance_ip == 'localhost' %}local{% else %}ssh{% endif %}"
1111
ansible_ssh_user: "{{ ansible_ssh_user|default('root') }}"
1212
ansible_ssh_port: "{{ ansible_ssh_port|default(22) }}"
13-
ansible_python_interpreter: "/usr/bin/python3"
13+
ansible_python_interpreter: /usr/bin/python3
1414
algo_provider: "{{ algo_provider }}"
1515
algo_server_name: "{{ algo_server_name }}"
1616
algo_ondemand_cellular: "{{ algo_ondemand_cellular }}"
@@ -33,7 +33,7 @@
3333
wait_for:
3434
port: "{{ ansible_ssh_port|default(22) }}"
3535
host: "{{ cloud_instance_ip }}"
36-
search_regex: "OpenSSH"
36+
search_regex: OpenSSH
3737
delay: 10
3838
timeout: 320
3939
state: present
@@ -44,8 +44,7 @@
4444
when:
4545
- pki_in_tmpfs
4646
- not algo_store_pki
47-
- ansible_system == "Darwin" or
48-
ansible_system == "Linux"
47+
- ansible_system == "Darwin" or ansible_system == "Linux"
4948

5049
- debug:
5150
var: IP_subject_alt_name

0 commit comments

Comments
 (0)