Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2016
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. [defaults]
  2.  
  3. host_key_checking = False
  4. hostfile = inventory
  5. deprecation_warnings = False
  6. [privilege_escalation]
  7. become = yes
  8. become_user = root
  9. become_method = sudo
  10.  
  11. Inventory file
  12.  
  13.  
  14.  
  15. host1 ansible_ssh_host==10.30.24.154
  16.  
  17. [webservers]
  18. host1
  19.  
  20. [datacenter:children]
  21. webservers
  22.  
  23.  
  24. [datacenter:vars]
  25. ansible_ssh_user=root
  26. ansible_ssh_pass=password
  27.  
  28.  
  29.  
  30.  
  31. /roles/webserver/tasks/main.yaml
  32.  
  33. ---
  34. - name: start jboss server
  35. remote_user: root
  36. command: sh /home/tcprod/schaitanya/first.sh
  37.  
  38.  
  39. webserver.yaml
  40.  
  41. ---
  42. - hosts: webservers
  43. gather_facts: yes
  44. roles:
  45. - webserver
  46.  
  47.  
  48. I used below command to execute
  49.  
  50. ansible-playbook webserver.yaml
  51.  
  52. Below is the first.sh file for scenario1
  53.  
  54. #!/bin/bash
  55. # My first script
  56.  
  57.  
  58. /usr/jboss/bin/run.sh -c production -b 0.0.0.0
  59.  
  60. #!/bin/bash
  61. # My first script
  62. echo "I am able to run as root user"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement