Skip to content

Commit a6567d3

Browse files
committed
Улучшил поддержку 8-го CentOS и openSUSE Leap\Tumbleweed.
Добавил переменную `http_or_https` для тех, кто пользуется кэширующими прокси. Протестировал работу на Fedora 33. Добавил примеров в README.md.
1 parent f245788 commit a6567d3

6 files changed

Lines changed: 61 additions & 52 deletions

File tree

README.md

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ Install [Snap](https://snapcraft.io/) for Linux.
1010
platforms:
1111
- name: Fedora
1212
versions:
13-
- 31
14-
- 32
13+
- 33
1514
- name: Ubuntu
1615
versions:
1716
- xenial
@@ -37,14 +36,48 @@ None.
3736
3837
## Role Variables
3938
40-
None.
39+
```yaml
40+
# If you *NOT* use apt-cacher-ng or other caching proxy - select "https".
41+
http_or_https: http
42+
```
4143
4244
## Dependencies
4345
4446
[min_ansible_version: 2.8](https://docs.ansible.com/ansible/latest/modules/snap_module.html)
4547
48+
## HowTo
49+
50+
### How to install role
51+
52+
Over `ansible-galaxy`:
53+
54+
```bash
55+
ansible-galaxy install don_rumata.ansible_role_install_snap
56+
```
57+
58+
Over `bash+git`:
59+
60+
```bash
61+
git clone https://github.com/don-rumata/ansible-role-install-snap don_rumata.ansible_role_install_snap
62+
```
63+
4664
## Example Playbook
4765

66+
Install latest `snapd` on Linux over package manager of you distro:
67+
68+
`install-snap.yml`:
69+
70+
```yaml
71+
- name: Install Snap
72+
hosts: all
73+
strategy: free
74+
serial:
75+
- "100%"
76+
roles:
77+
- don_rumata.ansible_role_install_snap
78+
tasks:
79+
```
80+
4881
`install-firefox-over-snap.yml`:
4982

5083
```yaml
@@ -54,7 +87,7 @@ None.
5487
serial:
5588
- "100%"
5689
roles:
57-
- ansible-role-install-snap
90+
- don_rumata.ansible_role_install_snap
5891
tasks:
5992
6093
- name: Install FF over snap

defaults/main.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
---
1+
---
2+
# If you *NOT* use apt-cacher-ng or other caching proxy - select "https".
3+
http_or_https: http
4+
# http_or_https: https

meta/main.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ galaxy_info:
1111
platforms:
1212
- name: Fedora
1313
versions:
14-
- 32
15-
- 31
14+
- 33
1615
- name: Ubuntu
1716
versions:
1817
- focal

tasks/install-4-redhat-yum.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
# https://snapcraft.io/docs/installing-snap-on-centos
3-
- name: Add EPEL repo
3+
- name: Add EPEL repo 4 CentOS 7\RHEL
44
when:
55
- ansible_os_family == 'RedHat'
66
- ansible_pkg_mgr == 'yum'
@@ -10,9 +10,20 @@
1010
ansible_python_interpreter: /usr/bin/python2.7
1111
become: yes
1212
# https://fedoraproject.org/wiki/EPEL
13-
yum:
13+
package:
1414
name:
15-
- https://dl.fedoraproject.org/pub/epel/epel-release-latest-{{ ansible_distribution_major_version }}.noarch.rpm
15+
- epel-release
16+
state: present
17+
18+
- name: Add EPEL repo 4 CentOS 8+\RHEL
19+
when:
20+
- ansible_os_family == 'RedHat'
21+
- ansible_pkg_mgr == 'dnf'
22+
- ansible_distribution != 'Fedora'
23+
become: yes
24+
package:
25+
name:
26+
- epel-release
1627
state: present
1728

1829
- name: Install snapd and config service 4 enterprise RHEL-like
@@ -22,7 +33,7 @@
2233
become: yes
2334
vars:
2435
ansible_python_interpreter: /usr/bin/python2.7
25-
yum:
36+
package:
2637
name:
2738
- snapd
2839
state: present

tasks/install-4-suse-zypper.yml

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,42 +4,26 @@
44
when:
55
- ansible_system == 'Linux'
66
- ansible_os_family == 'Suse'
7-
- ansible_distribution == 'openSUSE Tumbleweed'
87
- ansible_pkg_mgr == 'zypper'
8+
- ansible_distribution == 'openSUSE Tumbleweed'
99
become: yes
1010
zypper_repository:
1111
name: system_snappy
12-
repo: "https://download.opensuse.org/repositories/system:/snappy/{{ ansible_distribution | replace(' ', '_') }}/"
12+
repo: "{{ http_or_https }}://download.opensuse.org/repositories/system:/snappy/{{ ansible_distribution | replace(' ', '_') }}/"
1313
auto_import_keys: yes
1414
runrefresh: yes
1515
state: present
16-
tags:
17-
- linux
18-
- snap
19-
- install
20-
- suse
21-
- opensuse
22-
- zypper
23-
- rpm
2416

2517
- name: Add repo snapd 4 OpenSUSE Leap
2618
when:
2719
- ansible_system == 'Linux'
2820
- ansible_os_family == 'Suse'
29-
- ansible_distribution == 'openSUSE Leap'
3021
- ansible_pkg_mgr == 'zypper'
22+
- ansible_distribution == 'openSUSE Leap'
3123
become: yes
3224
zypper_repository:
3325
name: system_snappy
34-
repo: "https://download.opensuse.org/repositories/system:/snappy/{{ ansible_distribution | replace(' ', '_') }}_{{ ansible_distribution_version }}/"
26+
repo: "{{ http_or_https }}://download.opensuse.org/repositories/system:/snappy/{{ ansible_distribution | replace(' ', '_') }}_{{ ansible_distribution_version }}/"
3527
auto_import_keys: yes
3628
runrefresh: yes
3729
state: present
38-
tags:
39-
- linux
40-
- snap
41-
- install
42-
- suse
43-
- opensuse
44-
- zypper
45-
- rpm

tasks/main.yml

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,6 @@
1717
notify:
1818
- start-snapd-socket
1919
- start-snapd-apparmor
20-
tags:
21-
- linux
22-
- snap
23-
- install
24-
- debian
25-
- ubuntu
26-
- deb
2720

2821
- name: Enable and start snapd service 4 any Linux distros
2922
when:
@@ -34,10 +27,6 @@
3427
name: snapd
3528
state: started
3629
enabled: yes
37-
tags:
38-
- linux
39-
- snap
40-
- service
4130

4231
- name: Get status about /snap 4 any Linux distros
4332
when:
@@ -46,11 +35,6 @@
4635
stat:
4736
path: /snap
4837
register: root_snap_present
49-
tags:
50-
- linux
51-
- snap
52-
- symlink
53-
- ln
5438

5539
# https://snapcraft.io/docs/installing-snap-on-red-hat
5640
- name: Create snapd symlink 4 any Linux distros
@@ -62,8 +46,3 @@
6246
src: /var/lib/snapd/snap
6347
dest: /snap
6448
state: link
65-
tags:
66-
- linux
67-
- snap
68-
- symlink
69-
- ln

0 commit comments

Comments
 (0)