Ansible - 如何检查物理内存和可用磁盘是否大于某个值?
Ansible - How to check the physical memory and free disk is greater than some value?
如何编写 ansible 任务来检查物理内存是否 >=128 MB 且可用磁盘是否 >= 256 MB。我试图获取输出,但我不确定如何继续。
# Check the physical disk memory 128 MB and free disk 256 MB
- name: check the physical memory
command: vmstat -s
register: phy_mem
当你开始一个 playbook 时,Ansible 的第一个任务总是
TASK [Gathering Facts]
此任务获取 Ansible 使用但可在您的剧本中使用的一些内部变量。
例如内存检查查看变量 ansible_memory_mb.real.total
- assert:
that:
- ansible_memtotal_mb >= 128
现在您需要所有内部变量的列表:
ansible -m setup hostname
这是完整列表(名称和内容可能在新旧 Ansible 版本之间发生变化)
版本 2.3 来源:https://docs.ansible.com/ansible/2.3/setup_module.html
当前来源:https://docs.ansible.com/ansible/latest/user_guide/playbooks_vars_facts.html
如何编写 ansible 任务来检查物理内存是否 >=128 MB 且可用磁盘是否 >= 256 MB。我试图获取输出,但我不确定如何继续。
# Check the physical disk memory 128 MB and free disk 256 MB
- name: check the physical memory
command: vmstat -s
register: phy_mem
当你开始一个 playbook 时,Ansible 的第一个任务总是
TASK [Gathering Facts]
此任务获取 Ansible 使用但可在您的剧本中使用的一些内部变量。
例如内存检查查看变量 ansible_memory_mb.real.total
- assert:
that:
- ansible_memtotal_mb >= 128
现在您需要所有内部变量的列表:
ansible -m setup hostname
这是完整列表
版本 2.3 来源:https://docs.ansible.com/ansible/2.3/setup_module.html
当前来源:https://docs.ansible.com/ansible/latest/user_guide/playbooks_vars_facts.html