Ad-Hoc Ansible Commands Flashcards

1
Q

what id ad-hoc command

A

Are effectively one-liners

One can run ansible either ad-hoc or as a playbook

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Use cases for ad-hoc

A
  1. Operational commands
    - -checking logs
    - -daemon control
    - -process management
  2. Informational commands
    - -check installed software
    - -check system properties
  3. Research
    - - work with unfamiliar modules on test systems
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

ad-hoc vs playbook

A
1.
ad-hoc: command ansible
playbook: command ansible-playbook
2.
ad-hoc: effective for one-time command, operational activities
playbook: effective for deployment, routine tasks
3. ad-hoc similar to bash command
 playbook similar to bash script
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Common modules

A
Ping, no params
Setup- gather ansible facts, no params
Yum- params: name and state
Service- control daemons
params: name and state
User- manipulate system users
parans: name
Copy- copy files
params: src and dest
File- works with files
params: path
Git -interact with git repo
params: repo and dest
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Install/remove package on remote host

A

ansible -i inventory antony1 -b -m yum -a “name=htop state=latest”
ansible -i inventory antony1 -b -m yum -a “name=htop state=absent”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
Working with file module:
Create a file on remote host
Check if file exists
Update permissions of the file
Change the owner of file on remote host
A

ansible -i inventory antony1 -b -m file -a “path=/home/cloud_user/file1 state=touch”

ansible -i inventory antony1 -m file -a “path=/home/cloud_user/file1”

ansible -i inventory antony1 -b -m file -a “path=/home/cloud_user/file1 mode=0444”

ansible -i inventory antony1 -b -m file -a “path=/home/cloud_user/file1 owner=cloud_user”

ansible all -i inventory -b -m copy -a “src=/home/ansible/.ssh/id_rsa.pub dest=/home/supervisor/.ssh/authorized_keys/ owner=supervisor mode=0600”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Working with user module:

create a user on remote host

A

ansible -i inventory antony1 -b -m user -a “name=avance”

ansible -i inventory antony1 -b -m user -a “name=avance append=yes group=wheel”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Ensure auditd Is Enabled and Running on All Hosts

A

ansible all -b -m service -a “name=auditd state=started enabled=yes”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly