Difference between revisions of "Ansible File Commands"

From rbachwiki
Jump to navigation Jump to search
Line 36: Line 36:
   - name: run shell script
   - name: run shell script
     shell: "~/cfile.sh"
     shell: "~/cfile.sh"
=Create a Cron Job=
---
- name: Create a cron job
  hosts: server2
  tasks:
    - name: scedule cron
      cron:
        name: job secudeled by ansible
        minute: "0"
        hour: "10"
        day: "*"
        month: "*"
        weekday: "4"
        user: root
        job: "~/cfile.sh"

Revision as of 20:23, 22 June 2022

Copy File to remote servers

---
- name: copy file from local to remote
 hosts: all
 
 tasks:
 - name: copy file
   copy:
     src: ~/photo.jpg
     dest: ~/    
     owner: root
     group: root
     mode: 0777

Change Permission of file on remote server

---
- name: change permission on remote
 hosts: all

 tasks:
 - name: change permission
   file:
     path: ~/photo.jpg
     owner: root
     group: root
     mode: 0666

Run Shell Script on remote server

---
- name: run shell script
 hosts: all

 tasks:
  - name: run shell script
    shell: "~/cfile.sh"

Create a Cron Job

---
- name: Create a cron job
 hosts: server2
 tasks:
   - name: scedule cron
     cron: 
       name: job secudeled by ansible
       minute: "0"
       hour: "10"
       day: "*"
       month: "*"
       weekday: "4"
       user: root
       job: "~/cfile.sh"