RHCSA-Übungen und Aufgaben (10)

1. Hostinformationen in der Datei index.html des Webservers bereitstellen. Beim Zugriff auf den Webserver werden die folgenden Informationen angezeigt:

127.0.0.1       localhost localhost.localdomain localhost4 localhost4.localdomain4 
::1             localhost localhost.localdomain localhost6 localhost6.localdomain6 
192.168.168.140   centos78master 
192.168.168.21   node01 
192.168.168.22   node02

Antwortcode:

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_fact.default_ipv4.address }} {
    
    {
    
     hostvars[host].ansible_facts.hostname }}
{
    
    % endfor %}

Schreiben Sie zuoye.yml:

---
- bash: all
  tasks:
  	- template:
  		src: index.html.j2
  		dest: /var/www/html
  	- service:
  		name: httpd
  		state: started
  	- service:
  		name: firewalld
  		state: stopped

Das ist es

Acho que você gosta

Origin blog.csdn.net/Nirvana92/article/details/128439930
Recomendado
Clasificación