Ad Hoc Commands Flashcards Preview

Ansible > Ad Hoc Commands > Flashcards

Flashcards in Ad Hoc Commands Deck (11)
Loading flashcards...
1
Q

Learn about your environment

A

ansible [group] -a “hostname”
ansible [group] -a “date”
ansible [group] -a “ free -m”
(-a MODULE_ARGS, –args=MODULE_ARGS module arguments)

2
Q

Make changes using Ansible modules

A

ansible [group] -s -m yum -a “name=ntp state=present”
-m MODULE_NAME, –module-name=MODULE_NAME
-s, –sudo run operations with sudo (nopasswd)
ansible [group] -s -m service -a “name=ntpd state=started\
enabled=yes”
ansible [group] -s -a “service ntpd start”

3
Q

Configure Application Servers

A

ansible app -s -m yum -a “name=MySQL-python state=present”
ansible app -s -m yum -a “name=python-setuptools state=present”
ansible app -s -m easy_install -a “name=django state=present”

4
Q

Configure Database Server

A

ansible db -s -m yum -a “name=mariadb-server state=present”
ansible db -s -m service -a “name=mariadb state=started enabled=yes”
ansible db -s -a “firewall-cmd –permanent –add-port=3306/tcp”

5
Q

Manage Groups and Users

A

ansible app -s -m group -a “name=admin state=present”
ansible app -s -m user -a “name=johndoe group=admin createhome=yes”
ansible app -s -m user -a “name=johndoe state=absent remove=yes”

6
Q

Manage packages

A

ansible app -s -m package -a “name=git state=present”

7
Q

Get information on file

A

ansible app -m stat -a “path=/etc/hosts”

8
Q

Copy a file

A

ansible app -m copy -a “scr=/etc/hosts dest=/tmp/hosts”

9
Q

Receive file from server

A

ansible app -s -m fetch -a “scr=/etc/hosts dest=/tmp”

10
Q

Create directory and symlink

A

ansible app -m file -a “dest=/tmp/dir mode=644 state=directory”
ansible app -m file -a “scr=/tmp/dir dest=/dest/symlink owner=root group=root state=link”

11
Q

Delete file

A

ansible app -m file -a “dest=/tmp/test state=absent”