diff --git a/README.md b/README.md index d1f91dc..325acea 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,7 @@ Install [Snap](https://snapcraft.io/) for Linux. platforms: - name: Fedora versions: - - 31 - - 32 + - 33 - name: Ubuntu versions: - xenial @@ -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 @@ -54,7 +87,7 @@ None. serial: - "100%" roles: - - ansible-role-install-snap + - don_rumata.ansible_role_install_snap tasks: - name: Install FF over snap diff --git a/defaults/main.yml b/defaults/main.yml index 73b314f..1690459 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1 +1,4 @@ ---- \ No newline at end of file +--- +# If you *NOT* use apt-cacher-ng or other caching proxy - select "https". +http_or_https: http +# http_or_https: https diff --git a/meta/main.yml b/meta/main.yml index 369cfbd..c7f1310 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -11,8 +11,7 @@ galaxy_info: platforms: - name: Fedora versions: - - 32 - - 31 + - 33 - name: Ubuntu versions: - focal diff --git a/tasks/install-4-redhat-yum.yml b/tasks/install-4-redhat-yum.yml index 699fbb5..5c96333 100644 --- a/tasks/install-4-redhat-yum.yml +++ b/tasks/install-4-redhat-yum.yml @@ -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' @@ -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 @@ -22,7 +33,7 @@ become: yes vars: ansible_python_interpreter: /usr/bin/python2.7 - yum: + package: name: - snapd state: present diff --git a/tasks/install-4-suse-zypper.yml b/tasks/install-4-suse-zypper.yml index 43f1a86..d249c26 100644 --- a/tasks/install-4-suse-zypper.yml +++ b/tasks/install-4-suse-zypper.yml @@ -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 diff --git a/tasks/main.yml b/tasks/main.yml index 6a14951..a6a3091 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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: @@ -34,10 +27,6 @@ name: snapd state: started enabled: yes - tags: - - linux - - snap - - service - name: Get status about /snap 4 any Linux distros when: @@ -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 @@ -62,8 +46,3 @@ src: /var/lib/snapd/snap dest: /snap state: link - tags: - - linux - - snap - - symlink - - ln