Created
May 7, 2022 19:18
-
-
Save vagnernogueira/55f95440a1623de5790caf08c3b17571 to your computer and use it in GitHub Desktop.
Ansible Playbooks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
# Instalação do docker em distro Ubuntu no WSL 2 | |
# Use | |
# sudo ansible-playbook install-docker.yml | |
# Referências | |
# (1) https://github.com/codeedu/wsl2-docker-quickstart#docker-engine-docker-nativo-diretamente-instalado-no-wsl2 | |
# (2) https://cloudinfrastructureservices.co.uk/how-to-install-docker-compose-using-ansible-playbook/ | |
- hosts: localhost | |
#become: true | |
#become_user: root | |
tasks: | |
- name: Install apt-transport-https | |
apt: | |
name: ['apt-transport-https','ca-certificates', 'lsb-release', 'gnupg','curl'] | |
state: latest | |
update_cache: true | |
- name: Add signing key | |
apt_key: | |
url: "https://download.docker.com/linux/{{ ansible_distribution | lower }}/gpg" | |
keyring: /usr/share/keyrings/docker-archive-keyring.gpg | |
state: present | |
- name: Add repository into sources list | |
apt_repository: | |
repo: "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} stable" | |
state: present | |
filename: docker | |
- name: Install Docker | |
apt: | |
name: | |
- docker-ce | |
- docker-ce-cli | |
- containerd.io | |
state: latest | |
update_cache: true | |
- name: Add "vagner" user to "docker" group | |
remote_user: vagner | |
user: | |
name: "vagner" | |
group: "docker" | |
append: yes | |
- name: Install docker-compose from official github repo | |
remote_user: vagner | |
get_url: | |
url : https://github.com/docker/compose/releases/download/v2.5.0/docker-compose-linux-x86_64 | |
dest: /usr/local/bin/docker-compose | |
mode: 'u+x,g+x' | |
force: yes | |
- name: Link docker-compose | |
file: | |
src: "/usr/local/bin/docker-compose" | |
dest: "/usr/bin/docker-compose" | |
state: link | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
# Atualização da distro Ubuntu no WSL 2 | |
# Use | |
# sudo ansible-playbook update-ubuntu.yml | |
- hosts: localhost | |
#become: true | |
#become_user: root | |
tasks: | |
- name: Update apt repo and cache | |
apt: update_cache=yes force_apt_get=yes cache_valid_time=3600 | |
- name: Upgrade all packages | |
apt: upgrade=dist force_apt_get=yes | |
- name: Check if a reboot is needed | |
register: reboot_required_file | |
stat: path=/var/run/reboot-required get_md5=no | |
- name: Show reboot message | |
debug: | |
msg: "Rebook necessario!" | |
when: reboot_required_file.stat.exists | |
- name: Show final message | |
debug: | |
msg: "Update finish!" | |
when: not reboot_required_file.stat.exists | |
#- name: Reboot the box if kernel updated | |
# reboot: | |
# msg: "Reboot initiated by Ansible for kernel updates" | |
# connect_timeout: 5 | |
# reboot_timeout: 300 | |
# pre_reboot_delay: 0 | |
# post_reboot_delay: 30 | |
# test_command: uptime | |
# when: reboot_required_file.stat.exists |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment