- Ansible Quick Start Guide
- Mohamed Alibi
- 136字
- 2021-07-23 16:37:49
The hostname module
This is another simple module that does the simple job of changing a hostname. To make this module more exciting, we will use some of the playbook features with it. This module takes one input, the new hostname, and changes the hostname of the remote host. We can use the playbook predefined variable, {{ inventory_hostname }}. This variable calls the hostname for the Ansible inventory and uses it with the playbook.
First, we need to change the inventory file to look as follows:
[servers]
server0 ansible_host=192.168.10.10
server1 ansible_host=192.168.10.11
server2 ansible_host=192.168.10.12
Then, we use the following playbook:
- name: change hostname
hostname:
name: "{{ inventory_hostname }}"
After executing the playbook, you can simply test it out using an ad hoc Ansible command:
ansible -m shell -a hostname servers
The result should look as follows:
推薦閱讀
- 繪制進(jìn)程圖:可視化D++語言(第1冊(cè))
- Practical Data Analysis
- Visual FoxPro 6.0數(shù)據(jù)庫(kù)與程序設(shè)計(jì)
- Java開發(fā)技術(shù)全程指南
- PIC單片機(jī)C語言非常入門與視頻演練
- Windows程序設(shè)計(jì)與架構(gòu)
- Hands-On Cybersecurity with Blockchain
- Hands-On Linux for Architects
- 筆記本電腦維修90個(gè)精選實(shí)例
- 悟透AutoCAD 2009案例自學(xué)手冊(cè)
- 網(wǎng)絡(luò)服務(wù)搭建、配置與管理大全(Linux版)
- Deep Learning Essentials
- Hands-On Geospatial Analysis with R and QGIS
- 百度智能小程序:AI賦能新機(jī)遇
- iLike就業(yè)SQL多功能教材