Skip to content

Commit

Permalink
Улучшил поддержку 8-го CentOS и openSUSE Leap\Tumbleweed.
Browse files Browse the repository at this point in the history
Добавил переменную `http_or_https` для тех, кто пользуется кэширующими прокси.
Протестировал работу на Fedora 33.
Добавил примеров в README.md.
  • Loading branch information
don-rumata committed Apr 3, 2021
1 parent f245788 commit a6567d3
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 52 deletions.
41 changes: 37 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ Install [Snap](https://snapcraft.io/) for Linux.
platforms:
- name: Fedora
versions:
- 31
- 32
- 33
- name: Ubuntu
versions:
- xenial
Expand All @@ -37,14 +36,48 @@ None.
## Role Variables
None.
```yaml
# If you *NOT* use apt-cacher-ng or other caching proxy - select "https".
http_or_https: http
```
## Dependencies
[min_ansible_version: 2.8](https://docs.ansible.com/ansible/latest/modules/snap_module.html)
## HowTo
### How to install role
Over `ansible-galaxy`:

```bash
ansible-galaxy install don_rumata.ansible_role_install_snap
```

Over `bash+git`:

```bash
git clone https://github.com/don-rumata/ansible-role-install-snap don_rumata.ansible_role_install_snap
```

## Example Playbook

Install latest `snapd` on Linux over package manager of you distro:

`install-snap.yml`:

```yaml
- name: Install Snap
hosts: all
strategy: free
serial:
- "100%"
roles:
- don_rumata.ansible_role_install_snap
tasks:
```

`install-firefox-over-snap.yml`:

```yaml
Expand All @@ -54,7 +87,7 @@ None.
serial:
- "100%"
roles:
- ansible-role-install-snap
- don_rumata.ansible_role_install_snap
tasks:
- name: Install FF over snap
Expand Down
5 changes: 4 additions & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
---
---
# If you *NOT* use apt-cacher-ng or other caching proxy - select "https".
http_or_https: http
# http_or_https: https
3 changes: 1 addition & 2 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ galaxy_info:
platforms:
- name: Fedora
versions:
- 32
- 31
- 33
- name: Ubuntu
versions:
- focal
Expand Down
19 changes: 15 additions & 4 deletions tasks/install-4-redhat-yum.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
# https://snapcraft.io/docs/installing-snap-on-centos
- name: Add EPEL repo
- name: Add EPEL repo 4 CentOS 7\RHEL
when:
- ansible_os_family == 'RedHat'
- ansible_pkg_mgr == 'yum'
Expand All @@ -10,9 +10,20 @@
ansible_python_interpreter: /usr/bin/python2.7
become: yes
# https://fedoraproject.org/wiki/EPEL
yum:
package:
name:
- https://dl.fedoraproject.org/pub/epel/epel-release-latest-{{ ansible_distribution_major_version }}.noarch.rpm
- epel-release
state: present

- name: Add EPEL repo 4 CentOS 8+\RHEL
when:
- ansible_os_family == 'RedHat'
- ansible_pkg_mgr == 'dnf'
- ansible_distribution != 'Fedora'
become: yes
package:
name:
- epel-release
state: present

- name: Install snapd and config service 4 enterprise RHEL-like
Expand All @@ -22,7 +33,7 @@
become: yes
vars:
ansible_python_interpreter: /usr/bin/python2.7
yum:
package:
name:
- snapd
state: present
Expand Down
24 changes: 4 additions & 20 deletions tasks/install-4-suse-zypper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,26 @@
when:
- ansible_system == 'Linux'
- ansible_os_family == 'Suse'
- ansible_distribution == 'openSUSE Tumbleweed'
- ansible_pkg_mgr == 'zypper'
- ansible_distribution == 'openSUSE Tumbleweed'
become: yes
zypper_repository:
name: system_snappy
repo: "https://download.opensuse.org/repositories/system:/snappy/{{ ansible_distribution | replace(' ', '_') }}/"
repo: "{{ http_or_https }}://download.opensuse.org/repositories/system:/snappy/{{ ansible_distribution | replace(' ', '_') }}/"
auto_import_keys: yes
runrefresh: yes
state: present
tags:
- linux
- snap
- install
- suse
- opensuse
- zypper
- rpm

- name: Add repo snapd 4 OpenSUSE Leap
when:
- ansible_system == 'Linux'
- ansible_os_family == 'Suse'
- ansible_distribution == 'openSUSE Leap'
- ansible_pkg_mgr == 'zypper'
- ansible_distribution == 'openSUSE Leap'
become: yes
zypper_repository:
name: system_snappy
repo: "https://download.opensuse.org/repositories/system:/snappy/{{ ansible_distribution | replace(' ', '_') }}_{{ ansible_distribution_version }}/"
repo: "{{ http_or_https }}://download.opensuse.org/repositories/system:/snappy/{{ ansible_distribution | replace(' ', '_') }}_{{ ansible_distribution_version }}/"
auto_import_keys: yes
runrefresh: yes
state: present
tags:
- linux
- snap
- install
- suse
- opensuse
- zypper
- rpm
21 changes: 0 additions & 21 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@
notify:
- start-snapd-socket
- start-snapd-apparmor
tags:
- linux
- snap
- install
- debian
- ubuntu
- deb

- name: Enable and start snapd service 4 any Linux distros
when:
Expand All @@ -34,10 +27,6 @@
name: snapd
state: started
enabled: yes
tags:
- linux
- snap
- service

- name: Get status about /snap 4 any Linux distros
when:
Expand All @@ -46,11 +35,6 @@
stat:
path: /snap
register: root_snap_present
tags:
- linux
- snap
- symlink
- ln

# https://snapcraft.io/docs/installing-snap-on-red-hat
- name: Create snapd symlink 4 any Linux distros
Expand All @@ -62,8 +46,3 @@
src: /var/lib/snapd/snap
dest: /snap
state: link
tags:
- linux
- snap
- symlink
- ln

0 comments on commit a6567d3

Please sign in to comment.