[root@controller home]# cat createfile.yml
- hosts: localhost
become: true
tasks:
- name: Create a file
file: path=/home/kiran/kiran.txt state=touch
[root@controller home]#
- hosts: localhost
become: true
tasks:
- name: Create a file
file: path=/home/kiran/kiran.txt state=touch
[root@controller home]#
[root@controller home]# ansible-playbook createfile.yml
PLAY [localhost] *************************************************************************************************************************************
TASK [Gathering Facts] *******************************************************************************************************************************
ok: [localhost]
TASK [Create a file] *********************************************************************************************************************************
changed: [localhost]
PLAY RECAP *******************************************************************************************************************************************
localhost : ok=2 changed=1 unreachable=0 failed=0
[root@controller home]# ls
createfile.yml kiran
[root@controller home]# cd kiran
[root@controller kiran]# ls -ltr
total 0
drwxr-xr-x. 2 kiran kiran 6 Oct 6 07:59 Templates
drwxr-xr-x. 2 kiran kiran 6 Oct 6 07:59 Public
drwxr-xr-x. 2 kiran kiran 6 Oct 6 07:59 Downloads
drwxr-xr-x. 2 kiran kiran 6 Oct 6 07:59 Documents
drwxr-xr-x. 2 kiran kiran 6 Oct 6 07:59 Desktop
drwxr-xr-x. 2 kiran kiran 6 Oct 6 07:59 Videos
drwxr-xr-x. 2 kiran kiran 6 Oct 6 07:59 Pictures
drwxr-xr-x. 2 kiran kiran 6 Oct 6 07:59 Music
-rw-r--r-- 1 root root 0 Oct 18 14:42 kiran.txt
[root@controller kiran]#
[root@controller home]# cat createdir.yml
- hosts: localhost
become: true
tasks:
- name: Create directory
file: path=/home/kiran/kiran state=directory mode=775 owner=kiran group=kiran
[root@controller home]# ansible-playbook createdir.yml
PLAY [localhost] *************************************************************************************************************************************
TASK [Gathering Facts] *******************************************************************************************************************************
ok: [localhost]
TASK [Create directory] ******************************************************************************************************************************
changed: [localhost]
PLAY RECAP *******************************************************************************************************************************************
localhost : ok=2 changed=1 unreachable=0 failed=0
root@controller home]# cd kiran
[root@controller kiran]# ls -ltr
total 0
drwxr-xr-x. 2 kiran kiran 6 Oct 6 07:59 Templates
drwxr-xr-x. 2 kiran kiran 6 Oct 6 07:59 Public
drwxr-xr-x. 2 kiran kiran 6 Oct 6 07:59 Downloads
drwxr-xr-x. 2 kiran kiran 6 Oct 6 07:59 Documents
drwxr-xr-x. 2 kiran kiran 6 Oct 6 07:59 Desktop
drwxr-xr-x. 2 kiran kiran 6 Oct 6 07:59 Videos
drwxr-xr-x. 2 kiran kiran 6 Oct 6 07:59 Pictures
drwxr-xr-x. 2 kiran kiran 6 Oct 6 07:59 Music
-rw-r--r-- 1 root root 0 Oct 18 14:42 kiran.txt
drwxrwxr-x 2 kiran kiran 6 Oct 18 14:47 kiran
[root@controller kiran]#
[root@controller home]# cat createdir.yml
- hosts: localhost
become: true
tasks:
- name: Create directory
file: path=/home/kiran/kiran state=directory mode=775 owner=kiran group=kiran
[root@controller home]# ansible-playbook createdir.yml
PLAY [localhost] *************************************************************************************************************************************
TASK [Gathering Facts] *******************************************************************************************************************************
ok: [localhost]
TASK [Create directory] ******************************************************************************************************************************
changed: [localhost]
PLAY RECAP *******************************************************************************************************************************************
localhost : ok=2 changed=1 unreachable=0 failed=0
root@controller home]# cd kiran
[root@controller kiran]# ls -ltr
total 0
drwxr-xr-x. 2 kiran kiran 6 Oct 6 07:59 Templates
drwxr-xr-x. 2 kiran kiran 6 Oct 6 07:59 Public
drwxr-xr-x. 2 kiran kiran 6 Oct 6 07:59 Downloads
drwxr-xr-x. 2 kiran kiran 6 Oct 6 07:59 Documents
drwxr-xr-x. 2 kiran kiran 6 Oct 6 07:59 Desktop
drwxr-xr-x. 2 kiran kiran 6 Oct 6 07:59 Videos
drwxr-xr-x. 2 kiran kiran 6 Oct 6 07:59 Pictures
drwxr-xr-x. 2 kiran kiran 6 Oct 6 07:59 Music
-rw-r--r-- 1 root root 0 Oct 18 14:42 kiran.txt
drwxrwxr-x 2 kiran kiran 6 Oct 18 14:47 kiran
[root@controller kiran]#
Comments
Post a Comment