From b603c18eb536acb0f0cd438f5bb86e9c4f63340f Mon Sep 17 00:00:00 2001 From: fedy95 Date: Thu, 7 Jan 2021 15:40:11 +0300 Subject: [PATCH] init-repo --- Makefile | 8 ++++++++ group_vars/all.yml | 1 + install.sh | 8 ++------ roles/common/tasks/main.yml | 16 ++++++++------- roles/docker/tasks/main.yml | 38 ++++++++++++++++++------------------ roles/firefox/tasks/main.yml | 9 ++++++++- 6 files changed, 47 insertions(+), 33 deletions(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5353fca --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +MAKEFLAGS += --silent + +.PHONY: * + +run: + ansible-playbook ansible-desktop.yml --ask-become-pass + +.DEFAULT_GOAL := run diff --git a/group_vars/all.yml b/group_vars/all.yml index d98fcdc..9e07aa7 100644 --- a/group_vars/all.yml +++ b/group_vars/all.yml @@ -4,3 +4,4 @@ aptcachetime: 3600 locale: "en_US.UTF-8" timezone: "Europe/Moscow" +lsb_release: 'focal' diff --git a/install.sh b/install.sh index b428951..53ebac2 100755 --- a/install.sh +++ b/install.sh @@ -1,7 +1,5 @@ #!/bin/bash -################### -# Install ansible # if ! grep -q "ansible/ansible" /etc/apt/sources.list /etc/apt/sources.list.d/*; then echo "Adding Ansible PPA" sudo apt-add-repository ppa:ansible/ansible -y @@ -15,9 +13,7 @@ else echo "Ansible already installed" fi -##################################### -# Display real installation process # echo "" -echo "Customize the playbook ansible-desktop.yml to suit your needs, then run ansible with :" -echo " ansible-playbook ansible-desktop.yml --ask-become-pass" +echo "Run ansible with:" +echo " make" echo "" diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml index f49c0d5..3f93013 100644 --- a/roles/common/tasks/main.yml +++ b/roles/common/tasks/main.yml @@ -12,15 +12,17 @@ replace: dest=/etc/apt/sources.list regexp='^#\s?deb(.+)http://(.+)/ubuntu(.+)$' replace='deb\1http://\2/ubuntu\3' backup=yes - name: Ensure that Aptitude repositories are up to date - apt: update_cache=yes cache_valid_time={{ aptcachetime }} + apt: + update_cache: yes + cache_valid_time: "{{ aptcachetime }}" - name: Install common packages - apt: pkg={{ item }} state=latest update_cache=yes cache_valid_time={{ aptcachetime }} - with_items: - - git - - make - - nano - - net-tools + apt: + name: "{{ item }}" + state: latest + update_cache: yes + cache_valid_time: "{{ aptcachetime }}" + loop: [ 'git', 'make', 'nano', 'net-tools'] - name: Upgrade installed packages apt: upgrade=yes diff --git a/roles/docker/tasks/main.yml b/roles/docker/tasks/main.yml index fc38091..e93a70c 100644 --- a/roles/docker/tasks/main.yml +++ b/roles/docker/tasks/main.yml @@ -1,46 +1,43 @@ --- +- name: Update apt cache + apt: + update_cache: yes + cache_valid_time: "{{ aptcachetime }}" + +- name: Upgrade all apt packages + apt: upgrade=dist + - name: Install docker packages apt: name: "{{ item }}" state: present update_cache: yes - with_items: - - apt-transport-https - - ca-certificates - - curl - - gnupg-agent - - software-properties-common - -- name: Add Docker s official GPG key - remote_user: ubuntu + cache_valid_time: "{{ aptcachetime }}" + loop: ['apt-transport-https', 'ca-certificates', 'curl', 'gnupg-agent', 'software-properties-common'] + +- name: Add Docker GPG key apt_key: url: https://download.docker.com/linux/ubuntu/gpg state: present - name: Verify that we have the key with the fingerprint - remote_user: ubuntu apt_key: id: 0EBFCD88 state: present - name: Add deb repository apt_repository: - repo: deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable + repo: deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ lsb_release }} stable state: present - update_cache: yes - -- name: Update apt packages - remote_user: ubuntu - apt: - update_cache: yes - name: Install docker - remote_user: ubuntu apt: - name: docker-ce + name: "{{ item }}" state: present update_cache: yes + cache_valid_time: "{{ aptcachetime }}" + loop: ['docker-ce', 'docker-ce-cli', 'containerd.io'] - name: Create Docker group group: name=docker state=present @@ -57,3 +54,6 @@ dest: /usr/local/bin/docker-compose force: no mode: 0755 + +- name: Upgrade installed packages + apt: upgrade=yes diff --git a/roles/firefox/tasks/main.yml b/roles/firefox/tasks/main.yml index 91c4394..b1ac93b 100644 --- a/roles/firefox/tasks/main.yml +++ b/roles/firefox/tasks/main.yml @@ -1,4 +1,11 @@ --- - name: Install Firefox - apt: pkg=firefox state=latest update_cache=yes cache_valid_time={{ aptcachetime }} + apt: + pkg: firefox + state: latest + update_cache: yes + cache_valid_time: "{{ aptcachetime }}" + +- name: Upgrade installed packages + apt: upgrade=yes