ansible example
Ansible Role
修改文件一行
- name: modify hard limit of max open files number
lineinfile:
path: /etc/security/limits.conf
regexp: '^root hard nofile'
insertafter: EOF
line: 'root hard nofile 654321'
文件是否存在
- name: verify if the binary is exist
stat:
path: "{{ deploy_dir }}/bin"
register: stat_binary
变量名不能有 “-”
rpm 解压
- name: unzip rpm file
shell: "{{ item }}"
with_items:
- "cd {{ deploy_dir }} && rpm2cpio {{ nebula_packages.name }} |cpio -div"
- "mv {{ deploy_dir }}/usr/local/nebula/bin {{ deploy_dir }}/"
- "mv {{ deploy_dir }}/usr/local/nebula/etc {{ deploy_dir }}/"
- "mv {{ deploy_dir }}/usr/local/nebula/share {{ deploy_dir }}/"
- "mv {{ deploy_dir }}/usr/local/nebula/scripts {{ deploy_dir }}/"
when:
- not stat_binary.stat.exists
- pkg == 'rpm'
end play
- name: Information
debug:
msg: "Must input 'yes', abort the playbook "
when:
- confirmed != 'yes'
- meta: end_play
when:
- confirmed != 'yes'

浙公网安备 33010602011771号