migrate
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
---
|
||||
- name: Install docker
|
||||
hosts: all
|
||||
become: true
|
||||
|
||||
tasks:
|
||||
- name: Install docker dependencies
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- apt-transport-https
|
||||
- ca-certificates
|
||||
- curl
|
||||
- gnupg-agent
|
||||
- software-properties-common
|
||||
update_cache: true
|
||||
|
||||
- name: Add docker gpg key
|
||||
ansible.builtin.apt_key:
|
||||
url: https://download.docker.com/linux/ubuntu/gpg
|
||||
state: present
|
||||
keyring: /etc/apt/keyrings/docker.gpg
|
||||
|
||||
- name: Add docker repository
|
||||
ansible.builtin.apt_repository:
|
||||
filename: docker
|
||||
repo: deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu {{ ansible_lsb.codename | lower }} stable
|
||||
state: present
|
||||
|
||||
- name: Install docker engine
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- docker-ce
|
||||
- docker-ce-cli
|
||||
- containerd.io
|
||||
- docker-buildx-plugin
|
||||
- docker-compose-plugin
|
||||
update_cache: true
|
||||
@@ -0,0 +1,46 @@
|
||||
# To create an Ansible playbook that checks if qemu-guest-agent is installed, and if not, installs it, you can use the ansible.builtin.package module, which can manage packages across various types of package managers.
|
||||
|
||||
# Below is a simple playbook that accomplishes this:
|
||||
|
||||
#_________________________________________________________________________________________
|
||||
---
|
||||
- name: Check and Install qemu-guest-agent
|
||||
hosts: all
|
||||
become: yes # Use this if you need elevated privileges to install packages
|
||||
tasks:
|
||||
- name: Check if qemu-guest-agent is installed
|
||||
ansible.builtin.package_facts:
|
||||
|
||||
- name: update apt cache
|
||||
command: apt update
|
||||
|
||||
- name: upgrade all packages
|
||||
command: apt upgrade -y
|
||||
|
||||
- name: Install qemu-guest-agent if not installed
|
||||
ansible.builtin.package:
|
||||
name: qemu-guest-agent
|
||||
state: present
|
||||
when: "'qemu-guest-agent' not in ansible_facts.packages"
|
||||
|
||||
#___________________________________________________________________________________________
|
||||
|
||||
# Explanation:
|
||||
#
|
||||
# hosts: all - This playbook will run on all hosts in your inventory.
|
||||
# become: yes - This allows the tasks to run with elevated privileges (root), which is often required for installing packages.
|
||||
# package_facts - This module gathers facts about installed packages on the target machine and stores them in ansible_facts.
|
||||
# package - This module installs the specified package. The state: present ensures the package is installed.
|
||||
# when condition - The when clause checks if qemu-guest-agent is present in the ansible_facts.packages. If it’s not installed, the package will be installed.
|
||||
|
||||
# Usage
|
||||
|
||||
# Save the above YAML content to a file, for instance, install_qemu_guest_agent.yml.
|
||||
|
||||
# Run the playbook using the following command:
|
||||
|
||||
# COMMAND TO RUN: ansible-playbook -i your_inventory_file install_qemu_guest_agent.yml
|
||||
|
||||
# Replace your_inventory_file with the path to your Ansible inventory file that defines your target hosts.
|
||||
|
||||
# This playbook should effectively install the qemu-guest-agent on any host where it is not already installed.
|
||||
@@ -0,0 +1,19 @@
|
||||
[servers]
|
||||
192.168.2.1
|
||||
192.168.2.2
|
||||
192.168.2.3
|
||||
192.168.2.7
|
||||
192.168.2.8
|
||||
192.168.2.9
|
||||
192.168.2.10
|
||||
192.168.2.13
|
||||
192.168.2.14
|
||||
192.168.2.16
|
||||
#192.168.2.17
|
||||
#192.168.2.18
|
||||
192.168.2.19
|
||||
192.168.2.20
|
||||
192.168.2.22
|
||||
192.168.2.23
|
||||
192.168.2.24
|
||||
150.136.35.94
|
||||
@@ -0,0 +1,23 @@
|
||||
---
|
||||
k3s:
|
||||
hosts:
|
||||
k3master1:
|
||||
ansible_host: 192.168.0.177
|
||||
ansible_user: 'miker'
|
||||
ansible_become: true
|
||||
ansible_become_method: sudo
|
||||
k3master2:
|
||||
ansible_host: 192.168.0.178
|
||||
ansible_user: 'miker'
|
||||
ansible_become: true
|
||||
ansible_become_method: sudo
|
||||
k3worker1:
|
||||
ansible_host: 192.168.0.179
|
||||
ansible_user: 'miker'
|
||||
ansible_become: true
|
||||
ansible_become_method: sudo
|
||||
k3worker2:
|
||||
ansible_host: 192.168.0.180
|
||||
ansible_user: 'miker'
|
||||
ansible_become: true
|
||||
ansible_become_method: sudo
|
||||
@@ -0,0 +1 @@
|
||||
192.168.0.176
|
||||
@@ -0,0 +1,55 @@
|
||||
---
|
||||
- name: Post install configuration with docker
|
||||
hosts: all
|
||||
become: true # Use this if you need sudo privileges
|
||||
tasks:
|
||||
- name: Update and Upgrade all packages
|
||||
apt:
|
||||
update_cache: yes
|
||||
upgrade: dist
|
||||
when: ansible_os_family == "Debian"
|
||||
|
||||
- name: Install PIP
|
||||
apt:
|
||||
name: python3-pip
|
||||
state: present
|
||||
when: ansible_os_family == "Debian"
|
||||
|
||||
- name: Install qemu-guest-agent
|
||||
apt:
|
||||
name: qemu-guest-agent
|
||||
state: present
|
||||
when: ansible_os_family == "Debian"
|
||||
|
||||
- name: Install docker dependencies
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- apt-transport-https
|
||||
- ca-certificates
|
||||
- curl
|
||||
- gnupg-agent
|
||||
- software-properties-common
|
||||
update_cache: true
|
||||
|
||||
- name: Add docker gpg key
|
||||
ansible.builtin.apt_key:
|
||||
url: https://download.docker.com/linux/ubuntu/gpg
|
||||
state: present
|
||||
keyring: /etc/apt/keyrings/docker.gpg
|
||||
|
||||
- name: Add docker repository
|
||||
ansible.builtin.apt_repository:
|
||||
filename: docker
|
||||
repo: deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu {{ ansible_lsb.codename | lower }} stable
|
||||
state: present
|
||||
|
||||
- name: Install docker engine
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- docker-ce
|
||||
- docker-ce-cli
|
||||
- containerd.io
|
||||
- docker-buildx-plugin
|
||||
- docker-compose-plugin
|
||||
update_cache: true
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
---
|
||||
- name: Update and upgrade apt packages
|
||||
hosts: all
|
||||
become: true
|
||||
|
||||
tasks:
|
||||
- name: Update packages with apt
|
||||
when: ansible_pkg_mgr == 'apt'
|
||||
ansible.builtin.apt:
|
||||
update_cache: true
|
||||
|
||||
- name: Upgrade packages with apt
|
||||
when: ansible_pkg_mgr == 'apt'
|
||||
ansible.builtin.apt:
|
||||
upgrade: dist
|
||||
Reference in New Issue
Block a user