commit 6d9e1b03a240c586cb13c34b64ad1c781ba22766 Author: Yosafat Marselino Date: Fri May 16 05:14:59 2025 -0400 Init commit diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..2f6dc7b --- /dev/null +++ b/Readme.md @@ -0,0 +1,3 @@ +## Jenkins CI Auto-deployment + +This script will be used by Jenkins diff --git a/curl_execute.yaml b/curl_execute.yaml new file mode 100644 index 0000000..e422517 --- /dev/null +++ b/curl_execute.yaml @@ -0,0 +1,36 @@ +--- +- name: Curl and execute scripts on target machine + hosts: target_hosts + become: yes # Use sudo if needed + tasks: + - name: Create temporary directory for scripts + file: + path: /tmp/downloaded_scripts + state: directory + mode: '0755' + + - name: Download scripts from remote sources + get_url: + url: "{{ item.url }}" + dest: "/tmp/downloaded_scripts/{{ item.name }}" + mode: '0755' # Make executable + loop: + - { name: 'script1.sh', url: 'https://example.com/scripts/script1.sh' } + - { name: 'script2.sh', url: 'https://example.com/scripts/script2.sh' } + register: downloaded_scripts + + - name: Execute downloaded scripts + shell: "/tmp/downloaded_scripts/{{ item.item.name }}" + loop: "{{ downloaded_scripts.results }}" + register: script_output + + - name: Display script execution results + debug: + msg: "{{ item.stdout_lines }}" + loop: "{{ script_output.results }}" + + - name: Clean up temporary directory + file: + path: /tmp/downloaded_scripts + state: absent + when: cleanup_after | default(true) diff --git a/inventory.ini b/inventory.ini new file mode 100644 index 0000000..7f153d7 --- /dev/null +++ b/inventory.ini @@ -0,0 +1,26 @@ +# inventory.ini + +# Define your target hosts +[target_hosts] +server1 ansible_host=192.168.8.54 +server2 ansible_host=10.0.0.15 +webserver ansible_host=example.com + +# Group variables for target_hosts +[target_hosts:vars] +ansible_user=ubuntu +#ansible_ssh_private_key_file=/var/lib/jenkins/ +# Or use password authentication +# ansible_password=your_password + +# Optional: You can create additional host groups +[development] +server1 + +[production] +server2 +webserver + +# Optional: You can set variables specific to environments +[production:vars] +cleanup_after=true