iT邦幫忙

0

ansible 實例筆記4: 查看遠端

  • 分享至 

  • xImage
  •  

ansible 在下指令前,有些時候需要了解各台電腦的狀況,以下整理一些學習指令供大家參考:

web7 便是您要安裝的群組電腦

ping web7 群組的電腦

ansible web7 -m ping

打印一串字

ansible web7 -m command -a 'echo Hello World on Docker.'

查看文件內容

ansible web7 -m shell -a 'more /etc/test/test.txt'
#以下指令很有用,因為有時下 yum 是 centos ,apt 是 ubuntu,需先了解 
ansible all -m setup -a 'filter=ansible_distribution*'

joulong@65a907c63da0:~/playbook/docker$ sudo ansible web9 -m setup -a 'filter=ansible_distribution*'
joulong2 | SUCCESS => {
    "ansible_facts": {
        "ansible_distribution": "Ubuntu",
        "ansible_distribution_file_parsed": true,
        "ansible_distribution_file_path": "/etc/os-release",
        "ansible_distribution_file_variety": "Debian",
        "ansible_distribution_major_version": "22",
        "ansible_distribution_release": "jammy",
        "ansible_distribution_version": "22.04",
        "discovered_interpreter_python": "/usr/bin/python3"
    },
    "changed": false
}
joulong3 | SUCCESS => {
    "ansible_facts": {
        "ansible_distribution": "Ubuntu",
        "ansible_distribution_file_parsed": true,
        "ansible_distribution_file_path": "/etc/os-release",
        "ansible_distribution_file_variety": "Debian",
        "ansible_distribution_major_version": "22",
        "ansible_distribution_release": "jammy",
        "ansible_distribution_version": "22.04",
        "discovered_interpreter_python": "/usr/bin/python3"
    },
    "changed": false
}


圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言