diff --git a/AIS/.lxc-create.yml.swp b/AIS/.lxc-create.yml.swp new file mode 100644 index 0000000..a5b5311 Binary files /dev/null and b/AIS/.lxc-create.yml.swp differ diff --git a/AIS/ansible.cfg b/AIS/ansible.cfg new file mode 100644 index 0000000..73ee9b1 --- /dev/null +++ b/AIS/ansible.cfg @@ -0,0 +1,2 @@ +[defaults] +inventory = ./inventory diff --git a/AIS/inventory b/AIS/inventory new file mode 100644 index 0000000..e379046 --- /dev/null +++ b/AIS/inventory @@ -0,0 +1,12 @@ +[lokal] +localhost ansible_connection=local + +[ais] +debian ansible_host=10.0.3.123 +suse ansible_host=10.0.3.187 +rocky ansible_host=10.0.3.114 +ubuntu ansible_host=10.0.3.250 + +[ais:vars] +ansible_user=ubuntu +ansible_password=ubuntu diff --git a/AIS/inventory.lxc b/AIS/inventory.lxc new file mode 100644 index 0000000..c5cc5c3 --- /dev/null +++ b/AIS/inventory.lxc @@ -0,0 +1,12 @@ +[lokal] +localhost ansible_connection=local + +[notme] +10.0.3.110 ansible_user=ubuntu ansible_password=ubuntu +10.0.3.55 ansible_user=ubuntu ansible_password=ubuntu + +[ais] +debian ansible_host=10.0.3.123 +suse ansible_host=10.0.3.187 +rocky ansible_host=10.0.3.114 +ubuntu ansible_host=10.0.3.250 diff --git a/AIS/lxc-create.yml b/AIS/lxc-create.yml new file mode 100644 index 0000000..f5ef97e --- /dev/null +++ b/AIS/lxc-create.yml @@ -0,0 +1,33 @@ +--- +- hosts: lokal + become: yes + + vars: + lxc_names: + - debian + - suse + - rocky + - ubuntu + + tasks: + - name: Create a started container + community.general.lxc_container: + name: "{{ item }}" + container_log: true + template: ubuntu + state: started + template_options: --release focal + #container_command: | + # hostname -I + with_items: "{{ lxc_names }}" + register: lvm_container_info + + - name: Variable ausgeben + debug: + msg: "Der Container {{ item.item }} hat {{ item.lxc_container.ips[0] }}" + with_items: "{{ lvm_container_info.results }}" + + - name: Create inventory + template: + src: inventory.j2 + dest: inventory diff --git a/AIS/templates/inventory.j2 b/AIS/templates/inventory.j2 new file mode 100644 index 0000000..0c9f8ce --- /dev/null +++ b/AIS/templates/inventory.j2 @@ -0,0 +1,11 @@ +[lokal] +localhost ansible_connection=local + +[ais] +{% for container in lvm_container_info.results %} +{{ container.item }} ansible_host={{ container.lxc_container.ips[0] }} +{% endfor %} + +[ais:vars] +ansible_user=ubuntu +ansible_password=ubuntu