Skip to content

Commit

Permalink
Server setup initial steps
Browse files Browse the repository at this point in the history
  • Loading branch information
RK206 committed Nov 26, 2024
1 parent 3dfaca0 commit 4016484
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions ansible/provision/server_initial_setup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
## command using IP address -
# ansible-playbook -i 192.168.1.100, server_initial_setup.yml -e "git_branch=feature/new-feature ansible_user=ubuntu" --private-key=~/.ssh/id_rsa
## command using a specific host or group from your inventory.
# ansible-playbook -i doaj-hosts.ini server_initial_setup.yml --limit "hostname_or_ip" -e "git_branch=feature/new-feature"
---
- name: Setup VM for DOAJ application
hosts: all
become: true # Escalate privileges if needed
vars:
git_branch: "main"
tasks:
- name: Debug hostname
debug:
msg: "Running on host {{ inventory_hostname }}"
- name: Ensure Python3 and Git are installed
apt:
name:
- python3
- python3-venv
- git
state: present
update_cache: yes

- name: Create doaj directory
file:
path: /home/{{ ansible_user }}/doaj
state: directory
owner: "{{ ansible_user }}"
group: "{{ ansible_user }}"
mode: '0755'

- name: Create Python virtual environment
command: python3 -m venv /home/{{ ansible_user }}/doaj/venv
args:
creates: /home/{{ ansible_user }}/doaj/venv

- name: Create src/doaj directory
file:
path: /home/{{ ansible_user }}/doaj/src/doaj
state: directory
owner: "{{ ansible_user }}"
group: "{{ ansible_user }}"
mode: '0755'

- name: Clone git repository
git:
repo: "https://github.com/DOAJ/doaj.git"
dest: /home/{{ ansible_user }}/doaj/src/doaj
version: master
force: yes
become_user: "{{ ansible_user }}"

- name: Debug git branch
debug:
msg: "Using Git branch: {{ git_branch }}"

0 comments on commit 4016484

Please sign in to comment.