diff --git a/bootstrapCore.yml b/bootstrapCore.yml index 599cf3e..90ecd2f 100644 --- a/bootstrapCore.yml +++ b/bootstrapCore.yml @@ -4,13 +4,13 @@ become: true roles: - apt_upgrade - - hostnames - - ntp - - users - - sshd - - scripte - - cron - - ufw - - snmp + - bs_hostnames + - bs_ntp + - bs_users + - bs_sshd + - bs_scripte + - bs_cron + - bs_ufw + - bs_snmp ... \ No newline at end of file diff --git a/bootstrapRoot.yml b/bootstrapRoot.yml index 050916c..c268e57 100644 --- a/bootstrapRoot.yml +++ b/bootstrapRoot.yml @@ -3,9 +3,9 @@ remote_user: root roles: - apt_upgrade - - hostnames - - users - - sshd + - bs_hostnames + - bs_users + - bs_sshd # sshd schließt den root user von ssh aus, danach läuft das Playbook nicht mehr als root # Weiter geht's mit bootstrapCore diff --git a/bootstrapTest.yml b/bootstrapTest.yml new file mode 100644 index 0000000..671d526 --- /dev/null +++ b/bootstrapTest.yml @@ -0,0 +1,10 @@ +--- +- hosts: "{{ target }}" + remote_user: core + become: true + roles: + - kvm_setup + - kvm_installvm + + +... \ No newline at end of file diff --git a/host_vars/bbb.xitq.de b/host_vars/bbb.xitq.de index 5f84710..329c242 100644 --- a/host_vars/bbb.xitq.de +++ b/host_vars/bbb.xitq.de @@ -6,4 +6,14 @@ install_image: drives: sda,sdb passwordless_sudo: true + +install_vm: + osvariant: ubuntu20.04 + image: /home/core/tmp/ubuntu-22.04.1-live-server-amd64.iso + ram: 4096 + size: 20 + vcpus: 2 + + + ... \ No newline at end of file diff --git a/installimage b/installimageBuffer similarity index 100% rename from installimage rename to installimageBuffer diff --git a/roles/cron/files/environment.etc b/roles/bs_cron/files/environment.etc similarity index 100% rename from roles/cron/files/environment.etc rename to roles/bs_cron/files/environment.etc diff --git a/roles/cron/handlers/main.yml b/roles/bs_cron/handlers/main.yml similarity index 100% rename from roles/cron/handlers/main.yml rename to roles/bs_cron/handlers/main.yml diff --git a/roles/cron/tasks/main.yml b/roles/bs_cron/tasks/main.yml similarity index 100% rename from roles/cron/tasks/main.yml rename to roles/bs_cron/tasks/main.yml diff --git a/roles/hostnames/files/hosts b/roles/bs_hostnames/files/hosts similarity index 100% rename from roles/hostnames/files/hosts rename to roles/bs_hostnames/files/hosts diff --git a/roles/bs_hostnames/tasks/main.yml b/roles/bs_hostnames/tasks/main.yml new file mode 100644 index 0000000..817924e --- /dev/null +++ b/roles/bs_hostnames/tasks/main.yml @@ -0,0 +1,19 @@ +--- +- name: Set hostname + hostname: + name: "{{ inventory_hostname }}" + + +#- name: Copy hosts file to server +# copy: +# src: hosts +# dest: /etc/hosts +# owner: root +# group: root +# mode: 0644 + +- name: Write IP-Adress of active SSH-Connection to /etc/hosts file + debug: + var: ansible_facts['default_ipv4']['address'] + +... \ No newline at end of file diff --git a/roles/ntp/tasks/main.yml b/roles/bs_ntp/tasks/main.yml similarity index 100% rename from roles/ntp/tasks/main.yml rename to roles/bs_ntp/tasks/main.yml diff --git a/roles/scripte/files/bashlib b/roles/bs_scripte/files/bashlib similarity index 100% rename from roles/scripte/files/bashlib rename to roles/bs_scripte/files/bashlib diff --git a/roles/scripte/files/logCPUandETH b/roles/bs_scripte/files/logCPUandETH similarity index 100% rename from roles/scripte/files/logCPUandETH rename to roles/bs_scripte/files/logCPUandETH diff --git a/roles/scripte/files/ubuntuVersion b/roles/bs_scripte/files/ubuntuVersion similarity index 100% rename from roles/scripte/files/ubuntuVersion rename to roles/bs_scripte/files/ubuntuVersion diff --git a/roles/scripte/files/update b/roles/bs_scripte/files/update similarity index 100% rename from roles/scripte/files/update rename to roles/bs_scripte/files/update diff --git a/roles/scripte/tasks/main.yml b/roles/bs_scripte/tasks/main.yml similarity index 100% rename from roles/scripte/tasks/main.yml rename to roles/bs_scripte/tasks/main.yml diff --git a/roles/snmp/files/snmpd.conf b/roles/bs_snmp/files/snmpd.conf similarity index 100% rename from roles/snmp/files/snmpd.conf rename to roles/bs_snmp/files/snmpd.conf diff --git a/roles/snmp/handlers/main.yml b/roles/bs_snmp/handlers/main.yml similarity index 100% rename from roles/snmp/handlers/main.yml rename to roles/bs_snmp/handlers/main.yml diff --git a/roles/snmp/tasks/main.yml b/roles/bs_snmp/tasks/main.yml similarity index 100% rename from roles/snmp/tasks/main.yml rename to roles/bs_snmp/tasks/main.yml diff --git a/roles/sshd/handlers/main.yml b/roles/bs_sshd/handlers/main.yml similarity index 100% rename from roles/sshd/handlers/main.yml rename to roles/bs_sshd/handlers/main.yml diff --git a/roles/sshd/tasks/main.yml b/roles/bs_sshd/tasks/main.yml similarity index 100% rename from roles/sshd/tasks/main.yml rename to roles/bs_sshd/tasks/main.yml diff --git a/roles/ufw/files/startufw b/roles/bs_ufw/files/startufw similarity index 100% rename from roles/ufw/files/startufw rename to roles/bs_ufw/files/startufw diff --git a/roles/ufw/handlers/main.yml b/roles/bs_ufw/handlers/main.yml similarity index 100% rename from roles/ufw/handlers/main.yml rename to roles/bs_ufw/handlers/main.yml diff --git a/roles/ufw/tasks/main.yml b/roles/bs_ufw/tasks/main.yml similarity index 100% rename from roles/ufw/tasks/main.yml rename to roles/bs_ufw/tasks/main.yml diff --git a/roles/users/files/authorized_keys_core b/roles/bs_users/files/authorized_keys_core similarity index 100% rename from roles/users/files/authorized_keys_core rename to roles/bs_users/files/authorized_keys_core diff --git a/roles/users/files/authorized_keys_root b/roles/bs_users/files/authorized_keys_root similarity index 100% rename from roles/users/files/authorized_keys_root rename to roles/bs_users/files/authorized_keys_root diff --git a/roles/users/tasks/main.yml b/roles/bs_users/tasks/main.yml similarity index 100% rename from roles/users/tasks/main.yml rename to roles/bs_users/tasks/main.yml diff --git a/roles/users/tasks/setup_sudo.yml b/roles/bs_users/tasks/setup_sudo.yml similarity index 100% rename from roles/users/tasks/setup_sudo.yml rename to roles/bs_users/tasks/setup_sudo.yml diff --git a/roles/users/tasks/setup_users.yml b/roles/bs_users/tasks/setup_users.yml similarity index 100% rename from roles/users/tasks/setup_users.yml rename to roles/bs_users/tasks/setup_users.yml diff --git a/roles/users/tasks/upload_pubkeys.yml b/roles/bs_users/tasks/upload_pubkeys.yml similarity index 100% rename from roles/users/tasks/upload_pubkeys.yml rename to roles/bs_users/tasks/upload_pubkeys.yml diff --git a/roles/hostnames/tasks/main.yml b/roles/hostnames/tasks/main.yml deleted file mode 100644 index 15749dc..0000000 --- a/roles/hostnames/tasks/main.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- -- name: Set hostname - hostname: - name: "{{ inventory_hostname }}" - -- name: Copy hosts file to server - copy: - src: hosts - dest: /etc/hosts - owner: root - group: root - mode: 0644 - - -... \ No newline at end of file diff --git a/roles/kvm_installvm/files/virtinstall_options b/roles/kvm_installvm/files/virtinstall_options new file mode 100644 index 0000000..a3f53d9 --- /dev/null +++ b/roles/kvm_installvm/files/virtinstall_options @@ -0,0 +1,11 @@ +virt-install \ +--name ubuntu2204 \ +--ram 4096 \ +--disk path=/var/kvm/images/ubuntu2204.img,size=20 \ +--vcpus 2 \ +--os-variant ubuntu22.04 \ +--network bridge=br0 \ +--graphics none \ +--console pty,target_type=serial \ +--location /home/ubuntu-22.04-live-server-amd64.iso,kernel=casper/vmlinuz,initrd=casper/initrd \ +--extra-args 'console=ttyS0,115200n8 \ No newline at end of file diff --git a/roles/kvm_installvm/tasks/main.yml b/roles/kvm_installvm/tasks/main.yml new file mode 100644 index 0000000..44f0c3b --- /dev/null +++ b/roles/kvm_installvm/tasks/main.yml @@ -0,0 +1,37 @@ +--- + +- name: Download Ubuntu 22.04 iso to user core's tmp dir + ansible.builtin.get_url: + url: https://releases.ubuntu.com/22.04/ubuntu-22.04.1-live-server-amd64.iso + dest: /home/core/tmp/ubuntu-22.04.1-live-server-amd64.iso + mode: '0640' + +- name: Download Ubuntu 20.04 iso to user core's tmp dir + ansible.builtin.get_url: + url: https://releases.ubuntu.com/focal/ubuntu-20.04.5-live-server-amd64.iso + dest: /home/core/tmp/ubuntu-20.04.1-live-server-amd64.iso + mode: '0640' + +- name: DEBUG variables TEST ONLY + debug: + msg: "{{ install_vm.ram }}" + + +- name: Install VM with default host-specific host_vars settings + shell: + #cmd: echo {{ install_vm.ram }} + cmd: virt-install --name {{ vm }} --ram {{ install_vm.ram }} --disk path=/var/lib/libvirt/images/{{ vm }}.img,size={{ install_vm.size }} --vcpus {{ install_vm.vcpus }} --os-variant {{ install_vm.osvariant }} --network bridge=br0 --graphics none --console pty,target_type=serial --location {{ install_vm.image }},kernel=casper/vmlinuz,initrd=casper/initrd --extra-args 'console=ttyS0,115200n8' + + + + +- name: Upload vm XML-Description to core's tmp dir + ansible.builtin.template: + src: default.xml + dest: /home/core/tmp/ + owner: core + group: users + mode: '0644' + + +... \ No newline at end of file diff --git a/roles/kvm_installvm/templates/default.xml b/roles/kvm_installvm/templates/default.xml new file mode 100644 index 0000000..e1ed832 --- /dev/null +++ b/roles/kvm_installvm/templates/default.xml @@ -0,0 +1,114 @@ + + vhostxpm + 15666f6a-c48b-49b1-a2f9-2b01193cb204 + XIT Projektmanagement + 6291456 + 4194304 + 4 + + hvm + + + + + + + + + Broadwell-noTSX-IBRS + + + + + + + destroy + restart + destroy + + + + + + /usr/bin/kvm-spice + + + + +
+ + + + + +
+ + +
+ + + +
+ + + +
+ + + +
+ + + +
+ + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + + + + + +
+ + + + + +
+ +