commit 4ef45d1aac9a57d8bedc2b8d3816caceaaf72d14 Author: root Date: Sun Sep 4 15:30:01 2022 +0200 220904 diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..0080c31 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,71 @@ +--- +- name: "add ansible user" + remote_user: root + ignore_unreachable: yes + user: + name: ansible + system: yes + home: /var/local/ansible + comment: 'ansible management' + password: '!' + shell: '/bin/bash' + +- name: "authorized_keys for ansible user" + remote_user: root + ignore_unreachable: yes + authorized_key: + user: ansible + key: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDWZi5nTI6zo3+cgGx5l163pEQXJ3aUyerqbHfQl9p8aB2bbe+vQl+Uc2Vrv8fvytAZizjPIIYdW5RqFAXrbNP+OpyFAONNZpX0omB8HLoHzOnmWpaCjMZp9XAdvWPknWFWWkwR5G5rbP5+dKeREzl4cAvW4GauEjaK4kUJF3K2HumVF6U3bzyDwnI+7h0zEbHddSOwAP1Opzla+WSdF+ZsiMdcVZE/mFxzd8sv1ZoO36sVZ1vItEAcols4qEAfwW8Gk/UjXI1XFRD1UrksAUxAc4ypu5oBVWtjMa429ZrCRbH2iU+TPbuUSXHJQMgTqsUgHrS9XkuS3EdbPA/aDMD1jhoYz2zyfAoCGdEBOuATlaoCOpOeSc9XIsasdVNwvtX2LCTlQe+LLOQzKiLaHEr/QmnLs8es8b68wtDlFIA2QAXYIfs8l+gBv3t3BIw7VPbMe8nb6hbTHFObDlVCyvXO2/6ZkOfRMgswFsQnGAqciowPxsjVer+I5hEBCMHgb6pxcUECxcxsc9P/w/z9LxGts9Ozyq55jzWMwvnFdarkzpMfWtt3QX7XG5B8OD4ghuMkX60GgvT7v1E7yTI/JtwXrsAc6jl1Qo4+TDdEYuBXe/LqyQzQ7GD1OoGRHIKCWyAQ9JiHcbUYX9p+vafXf0l1jelSg3O+cU+q+oZdGP178w== root@kavics' + +- name: "sudo for ansible user" + remote_user: root + ignore_unreachable: yes + lineinfile: + path: /etc/sudoers + line: "ansible ALL=(ALL) NOPASSWD: ALL" + +# as ansible user from here + +- name: delayed facts gathering + setup: + +- name: empty /etc/resolv.conf to avoid own hostname resolve errors + copy: + content: "" + dest: /etc/resolv.conf + tags: dns + +- name: set hostname + command: "hostname {{ hostname }}" + +- name: new /etc/hostname + copy: + dest: /etc/hostname + content: "{{ hostname }}\n" + +- name: new /etc/network/interfaces + template: + src: interfaces.t + dest: /etc/network/interfaces + +- name: new /etc/hosts + template: + src: hosts.t + dest: /etc/hosts + tags: dns + +- name: new /etc/resolv.conf + template: + src: resolv.conf.t + dest: /etc/resolv.conf + tags: dns + +- name: remove ssh host keys + shell: "rm /etc/ssh/ssh_host*key*" + +- name: create new ssh host keys + command: "dpkg-reconfigure openssh-server" + +#- name: postfix hostname ???? - nem kell, ezutan installaljuk csak + +# vim: set tabstop=2 shiftwidth=2 expandtab smarttab: diff --git a/templates/hosts.t b/templates/hosts.t new file mode 100644 index 0000000..a800dc2 --- /dev/null +++ b/templates/hosts.t @@ -0,0 +1,2 @@ +127.0.0.1 localhost +{{ ip }} {{ hostname }}.{{ domain }} {{ hostname }} diff --git a/templates/interfaces.t b/templates/interfaces.t new file mode 100644 index 0000000..3e29c80 --- /dev/null +++ b/templates/interfaces.t @@ -0,0 +1,13 @@ +# This file describes the network interfaces available on your system +# and how to activate them. For more information, see interfaces(5). + +source /etc/network/interfaces.d/* + +auto lo +iface lo inet loopback + +allow-hotplug eth0 +iface eth0 inet static + address {{ ip }} + netmask {{ netmask }} + gateway {{ gw }} diff --git a/templates/resolv.conf.t b/templates/resolv.conf.t new file mode 100644 index 0000000..dac558f --- /dev/null +++ b/templates/resolv.conf.t @@ -0,0 +1,5 @@ +search {{ domain }} +{% set nameservers = dns.split('+') %} +{% for a in nameservers %} +nameserver {{ a }} +{% endfor %}