From 67021cebc57de94cdc9d6c3c57fbbfc23b8decfe Mon Sep 17 00:00:00 2001 From: pgrondek Date: Tue, 26 May 2020 00:22:38 +0200 Subject: [PATCH] Move ubuntu to roles --- inventory/hosts.yml | 27 ++++++++----------- main.yml | 8 +++++- .../ubuntu/files}/etc/default/motd-news | 0 {server => roles/ubuntu/tasks}/cleanup.yml | 10 +++---- roles/ubuntu/tasks/main.yml | 4 +++ roles/ubuntu/tasks/timezone.yml | 6 +++++ roles/ubuntu/vars/main.yml | 2 ++ server/authorized_keys | 1 - server/timezone.yml | 14 ---------- 9 files changed, 33 insertions(+), 39 deletions(-) rename {server => roles/ubuntu/files}/etc/default/motd-news (100%) rename {server => roles/ubuntu/tasks}/cleanup.yml (72%) create mode 100644 roles/ubuntu/tasks/main.yml create mode 100644 roles/ubuntu/tasks/timezone.yml create mode 100644 roles/ubuntu/vars/main.yml delete mode 100644 server/authorized_keys delete mode 100644 server/timezone.yml diff --git a/inventory/hosts.yml b/inventory/hosts.yml index bf95a96..ba11d8b 100644 --- a/inventory/hosts.yml +++ b/inventory/hosts.yml @@ -1,20 +1,15 @@ --- all: children: - server: + docker_cluster: hosts: - prusa.lan: - iron-man.lan: - children: - docker_cluster: - hosts: - node-01.lan: - docker_node: node-01 - node-02.lan: - docker_node: node-02 - node-03.lan: - docker_node: node-03 - node-x86.lan: - docker_node: node-x86 - ansible_host: 192.168.50.186 - release: bionic + node-01.lan: + docker_node: node-01 + node-02.lan: + docker_node: node-02 + node-03.lan: + docker_node: node-03 + node-x86.lan: + docker_node: node-x86 + ansible_host: 192.168.50.186 + release: bionic diff --git a/main.yml b/main.yml index 48cb906..8af6c79 100644 --- a/main.yml +++ b/main.yml @@ -1,12 +1,18 @@ --- -- hosts: server +- hosts: iron-man.lan roles: - ssh + - ubuntu - hosts: prusa.lan roles: + - ssh - octoprint + - ubuntu - hosts: docker_cluster roles: + - ssh - docker-cluster + - ubuntu + diff --git a/server/etc/default/motd-news b/roles/ubuntu/files/etc/default/motd-news similarity index 100% rename from server/etc/default/motd-news rename to roles/ubuntu/files/etc/default/motd-news diff --git a/server/cleanup.yml b/roles/ubuntu/tasks/cleanup.yml similarity index 72% rename from server/cleanup.yml rename to roles/ubuntu/tasks/cleanup.yml index f410b1b..9dfa594 100644 --- a/server/cleanup.yml +++ b/roles/ubuntu/tasks/cleanup.yml @@ -1,11 +1,6 @@ --- -- name: cleanup ubuntu - hosts: server - become_method: sudo - become_user: root - become: yes - - tasks: +- become: yes + block: - name: clean packages apt: pkg: @@ -14,6 +9,7 @@ - lxd - lxd-client state: absent + - name: disable ubuntu ads copy: src: etc/default/motd-news diff --git a/roles/ubuntu/tasks/main.yml b/roles/ubuntu/tasks/main.yml new file mode 100644 index 0000000..e4e4550 --- /dev/null +++ b/roles/ubuntu/tasks/main.yml @@ -0,0 +1,4 @@ +--- +- import_tasks: cleanup.yml + +- import_tasks: timezone.yml diff --git a/roles/ubuntu/tasks/timezone.yml b/roles/ubuntu/tasks/timezone.yml new file mode 100644 index 0000000..43dc9da --- /dev/null +++ b/roles/ubuntu/tasks/timezone.yml @@ -0,0 +1,6 @@ +--- +- name: set timezone + become: yes + shell: + cmd: | + timedatectl set-timezone {{ timezone }} diff --git a/roles/ubuntu/vars/main.yml b/roles/ubuntu/vars/main.yml new file mode 100644 index 0000000..1cf7e81 --- /dev/null +++ b/roles/ubuntu/vars/main.yml @@ -0,0 +1,2 @@ +--- +timezone: Europe/Warsaw diff --git a/server/authorized_keys b/server/authorized_keys deleted file mode 100644 index f18e234..0000000 --- a/server/authorized_keys +++ /dev/null @@ -1 +0,0 @@ -ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDwTqV2idle6AQj179tAuAxZzodtTb2aMJKIEnL+tXfdsKsoc8kfQV3JMtq53hk6jRcH/9+FamCBqP/2s1xT4elKAZ7GWYBMi4HqGr8Qr7I1sK2m9dydrmW+iepmhGNDdKlYkEFc8aM9blbCTEN9RqqJiSomzDAIZQWiV2E/18MIxu3WYKJ561uzILkmB9o7UJbdAgOGbk6+GkBIwGCX5CwlX4Ro8wLv/i55/bg03N1lAbsCeDqaZX7ikiy2hnxAFH/EuY2g2WK4x9yUjhUe1MnCZy5SealSP76b9BHyJVYrxGVyAZOtlnewEXzbJXnyHGQg00hXeT8YtTlMSXaQVih pgrondek@farnsworth diff --git a/server/timezone.yml b/server/timezone.yml deleted file mode 100644 index 0d03269..0000000 --- a/server/timezone.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- -- name: set timezone - hosts: server - become_method: sudo - become_user: root - become: yes - vars: - timezone: Europe/Warsaw - - tasks: - - name: set timezone - shell: - cmd: | - timedatectl set-timezone {{ timezone }}