pulitux 2 rokov pred
rodič
commit
7d1443e954
5 zmenil súbory, kde vykonal 43 pridanie a 0 odobranie
  1. 9 0
      labo/ansible.cfg
  2. 1 0
      labo/host_vars/localhost
  3. 9 0
      labo/hosts.j2
  4. 15 0
      labo/inventory
  5. 9 0
      labo/set_hosts.yml

+ 9 - 0
labo/ansible.cfg

@@ -0,0 +1,9 @@
+[defaults]
+inventory=inventory
+remote_user=devops
+
+[privilege_escalation]
+become=true
+become_method=sudo
+become_user=root
+become_ask_pass=true

+ 1 - 0
labo/host_vars/localhost

@@ -0,0 +1 @@
+ansible_connection = smart

+ 9 - 0
labo/hosts.j2

@@ -0,0 +1,9 @@
+
+# {{ ansible_managed }}
+
+127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
+::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
+
+{% for host in groups['all'] %}
+{{ hostvars[host]['ansible_facts']['default_ipv4']['address'] }} {{ hostvars[host]['ansible_facts']['fqdn'] }} {{ hostvars[host]['ansible_facts']['hostname'] }}
+{% endfor %}

+ 15 - 0
labo/inventory

@@ -0,0 +1,15 @@
+[webservers]
+servera
+serverb
+
+[dbservers]
+serverc
+serverd
+
+[devops]
+servera
+serverc
+
+[prod]
+serverb
+serverd

+ 9 - 0
labo/set_hosts.yml

@@ -0,0 +1,9 @@
+- name: set /etc/hosts in managed hosts
+  hosts: all
+  remote_user: student
+  gather_facts: yes
+  tasks:
+    - name: template render
+      template:
+        src: hosts.j2
+        dest: /etc/hosts