move stuff to roles

This commit is contained in:
eneller
2022-09-03 17:57:46 +02:00
parent 2049f2ab2a
commit f1177aaec9
11 changed files with 94 additions and 107 deletions

8
hosts
View File

@@ -12,11 +12,7 @@ server[1:6]_oracle
server[1:6]_oracle server[1:6]_oracle
[arm64] [arm64]
server2_oracle server[2:6:2]_oracle
server4_oracle
server6_oracle
[amd64] [amd64]
server1_oracle server[1:5:2]_oracle
server3_oracle
server5_oracle

10
package_upgrade.yml Normal file
View File

@@ -0,0 +1,10 @@
---
- name: update apt-cache and upgrade
hosts: oracleServer
tasks:
- name: upgrade packages
become: true
package:
update_cache: yes
upgrade: 'yes'

View File

@@ -1,62 +0,0 @@
---
- name: Install Docker
# 'all' is okay here, because the fail task will force the user to specify a limit on the command line, using -l or --limit
hosts: all
tasks:
- name: checking limit arg
fail:
msg: "you must use -l or --limit - when you really want to use all hosts, use -l 'all'"
when: ansible_limit is not defined
run_once: true
- name: Install required system packages
become: true
apt:
pkg:
- ca-certificates
- curl
- gnupg
- lsb-release
- python3-pip
state: latest
update_cache: yes
- name: Add Docker GPG Key
become: true
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
# id: 9DC858229FC7DD38854AE2D88D81803C0EBFCD88
state: present
- name: Add Docker Repository
become: true
apt_repository:
repo: "deb [arch={{ arch }}] https://download.docker.com/linux/{{ansible_distribution|lower}} {{ansible_distribution_release}} stable"
state: present
- name: Install Docker packages
become: true
apt:
update_cache: yes
pkg:
- docker-ce
- docker-ce-cli
- containerd.io
- name: Install docker-compose using pip
pip:
name:
- docker-compose
- name: add user to docker group
become: true
user:
name: "{{ ansible_user_id }}"
groups:
- docker
append: yes
- name: Create docker folder
file:
path: "{{ansible_user_dir}}/docker"
state: directory

View File

@@ -1,22 +0,0 @@
---
- name: reboot machine if required
# 'all' is okay here, because the fail task will force the user to specify a limit on the command line, using -l or --limit
hosts: 'all'
tasks:
- name: checking limit arg
fail:
msg: "you must use -l or --limit - when you really want to use all hosts, use -l 'all'"
when: ansible_limit is not defined
run_once: true
- name: Check if reboot is required
stat:
path: /var/run/reboot-required
register: reboot_required_file
- name: Reboot if required
tags: disruptive
become: true
reboot:
when: reboot_required_file.stat.exists == true

View File

@@ -1,17 +0,0 @@
---
- name: update apt-cache and upgrade
# 'all' is okay here, because the fail task will force the user to specify a limit on the command line, using -l or --limit
hosts: all
tasks:
- name: checking limit arg
fail:
msg: "you must use -l or --limit - when you really want to use all hosts, use -l 'all'"
when: ansible_limit is not defined
run_once: true
- name: upgrade apt
become: true
apt:
update_cache: yes
upgrade: 'yes'

13
reboot_required.yml Normal file
View File

@@ -0,0 +1,13 @@
---
- name: reboot machine if required
# 'all' is okay here, because the fail task will force the user to specify a limit on the command line, using -l or --limit
hosts: 'all'
tasks:
- name: Force limit arg
include_role:
name: force_limitArg
- name: Reboot if required
include_role:
name: reboot_required

View File

@@ -0,0 +1,6 @@
---
- name: checking limit arg
fail:
msg: "you must use -l or --limit - when you really want to use all hosts, use -l 'all'"
when: ansible_limit is not defined
run_once: true

View File

@@ -0,0 +1 @@
release_branch_docker: "stable"

View File

@@ -0,0 +1,51 @@
- name: Install required system packages
become: true
apt:
pkg:
- ca-certificates
- curl
- gnupg
- lsb-release
- python3-pip
state: latest
update_cache: yes
- name: Add Docker GPG Key
become: true
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
# id: 9DC858229FC7DD38854AE2D88D81803C0EBFCD88
state: present
- name: Add Docker Repository
become: true
apt_repository:
repo: "deb [arch={{ arch }}] https://download.docker.com/linux/{{ansible_distribution|lower}} {{ansible_distribution_release}} stable"
state: present
- name: Install Docker packages
become: true
apt:
update_cache: yes
pkg:
- docker-ce
- docker-ce-cli
- containerd.io
- name: Install docker-compose using pip
pip:
name:
- docker-compose
- name: add user to docker group
become: true
user:
name: "{{ ansible_user_id }}"
groups:
- docker
append: yes
- name: Create docker folder
file:
path: "{{ansible_user_dir}}/docker"
state: directory

View File

@@ -0,0 +1,11 @@
---
- name: Check if reboot is required
stat:
path: /var/run/reboot-required
register: reboot_required_file
- name: Reboot if required
tags: disruptive
become: true
reboot:
when: reboot_required_file.stat.exists == true