MyAnsible - stanislawbartkowski/wikis GitHub Wiki
A bunch of convenient Ansible commands and samples.
(optional)
yum install epel-release
yum install ansible
vi /etc/ansible/hosts
pimiento[1:4]
velarize1
all is referencing the following nodes: pimiento1,pimiento2,pimiento3,pimiento4 and velarize1
ansible all -m ping
(pay attention to a comma after hostname)
ansible-playbok -i "<host name>," playbook.yml
lineinfile:
path: /etc/rc.local
state: present
line: '{{ item }}'
with_items:
- 'echo never > /sys/kernel/mm/transparent_hugepage/defrag'
- 'echo never > /sys/kernel/mm/transparent_hugepage/enabled'
Command | Description | Example |
---|---|---|
ansible all -a <command> | Run ad-hoc command | ansible all -a ls ansible all -a "yum install epel-release -y" ansible all -a "yum install java-1.8.0-openjdk-devel -y" |
ansible all -m copy -a "src=<source file> dest=<dest file or directory>" | Copy file to all hosts | ansible all -m copy -a "src=/etc/hosts dest=/etc" |
ansible all -m copy -a "src=<source file> dest=<dest file or directory> mode=preserve" | Copy file to all hosts and preserve permissions | ansible all -m copy -a "src=/etc/hosts dest=/etc mode=preserve" |
ansible all -m user -a "name=<user name>" | Add new user | ansible all -m user -a "name=uhdfs" |
ansible all -m user -a "name=<user name> state=absent" | Delete user | ansible all -m user -a "name=uhdfs state=absent" |
ansible all -m yum -a "name=<package name >" | Yum install | ansible all -m yum -a "name=git" |
ansible all -m yum -a "name='*' state=latest" | yum -y update |
ansible all -a "timedatectl set-timezone Europe/Warsaw"
ansible all -m yum -a "name=mlocate"
ansible all -m yum -a "name=java-11-openjdk-devel"
ansible all -m yum -a "name=openldap-clients,krb5-workstation,krb5-libs"
Description | Link |
---|---|
Disable Transparent Hugepages | https://github.com/stanislawbartkowski/wikis/blob/master/ansible/transparent.yml |
DB2 upgrade | https://github.com/stanislawbartkowski/db2upgrade |