Skip to content

Commit

Permalink
sync with github.com/readytotouch-yaaws/yaaws-go
Browse files Browse the repository at this point in the history
  • Loading branch information
YaroslavPodorvanov committed Oct 6, 2023
1 parent f949d13 commit 54a4fdd
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 130 deletions.
23 changes: 6 additions & 17 deletions Makefile.ansible
Original file line number Diff line number Diff line change
@@ -1,25 +1,14 @@
ansible-ping:
# https://askubuntu.com/questions/46424/how-do-i-add-ssh-keys-to-authorized-keys-file
# https://askubuntu.com/a/262074
# cat ~/.ssh/id_rsa.pub | ssh [email protected] "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
ansible -i ./scripts/ansible/hosts.txt all -m ping

ansible-install-docker-compose:
# https://docs.ansible.com/ansible/latest/network/getting_started/first_playbook.html
ansible-playbook -i ./scripts/ansible/hosts.txt ./scripts/ansible/install-docker-compose-playbook.yml

ansible-git-pull:
ansible-playbook -i ./scripts/ansible/hosts.txt ./scripts/ansible/git-pull.yml

# alias
agp: ansible-git-pull

ansible-make:
ansible-playbook -i ./scripts/ansible/hosts.txt ./scripts/ansible/make.yml
ansible-install-docker-compose:
ansible-playbook -i ./scripts/ansible/hosts.txt ./scripts/ansible/install-docker-compose.yml

ansible-shell:
# ansible -i ./scripts/ansible/hosts.txt all -m shell -a "ps aux"
ansible -i ./scripts/ansible/hosts.txt all -m shell -a "cd /var/go/u8views; env"
ansible-install-go:
ansible-playbook -i ./scripts/ansible/hosts.txt ./scripts/ansible/install-go.yml

ansible-go-install:
ansible-playbook -i ./scripts/ansible/hosts.txt ./scripts/ansible/go-install.yml
ansible-install-nodejs:
ansible-playbook -i ./scripts/ansible/hosts.txt ./scripts/ansible/install-nodejs.yml
44 changes: 13 additions & 31 deletions scripts/ansible/git-pull.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,19 @@
---
# https://fabianlee.org/2021/02/03/ansible-cloning-a-git-repository-that-requires-credentials/
- name: "Git clone u8views"
hosts: web
gather_facts: no
hosts: "web"
gather_facts: "no"
vars:
- REPOSITORY: "https://github.com/u8views/go-u8views.git"
- DESTINATION: "/var/go/u8views"

tasks:
- name: "/var/go/u8views"
file:
path: /var/go/u8views
state: directory
- name: "Ensure directory {{ DESTINATION }} exists"
ansible.builtin.file:
path: "{{ DESTINATION }}"
state: "directory"

- name: "git pull"
- name: "Git pull repository {{ REPOSITORY }}"
ansible.builtin.git:
repo: https://github.com/u8views/go-u8views.git
version: main
dest: /var/go/u8views

- name: "git status"
shell: "git status"
args:
chdir: "/var/go/u8views"
register: out
when: false
- debug:
var: out.stdout_lines
when: false

- name: "ls -la"
shell: "ls -la"
args:
chdir: "/var/go/u8views"
register: out
when: false
- debug:
var: out.stdout_lines
when: false
repo: "{{ REPOSITORY }}"
version: "main"
dest: "{{ DESTINATION }}"
58 changes: 0 additions & 58 deletions scripts/ansible/install-docker-compose-playbook.yml

This file was deleted.

60 changes: 60 additions & 0 deletions scripts/ansible/install-docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
- name: "Install Docker and Docker Compose"
hosts: "web"
gather_facts: "no"
vars:
- DOCKER_COMPOSE_VERSION: "2.22.0"

tasks:
- name: "Update apt cache"
apt:
update_cache: "yes"

- name: "Install required packages"
package:
name: "{{ item }}"
state: "present"
loop:
- "apt-transport-https"
- "ca-certificates"
- "curl"
- "software-properties-common"

- name: "Add Docker GPG key"
apt_key:
url: "https://download.docker.com/linux/ubuntu/gpg"
state: "present"

- name: "Add Docker APT repository"
apt_repository:
repo: "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
state: "present"

- name: "Install Docker"
package:
name: "docker-ce"
state: "present"

- name: "Start and enable Docker service"
service:
name: "docker"
state: "started"
enabled: "yes"

- name: "Install Docker Compose"
get_url:
url: "https://github.com/docker/compose/releases/download/v{{ DOCKER_COMPOSE_VERSION }}/docker-compose-{{ lookup('pipe', 'uname -s') }}-{{ lookup('pipe', 'uname -m') }}"
dest: "/usr/local/bin/docker-compose"
mode: "a+x"

- name: "Get Docker version"
command: "docker --version"
register: "docker_version"
- debug:
var: "docker_version.stdout"

- name: "Get Docker Compose version"
command: "docker-compose --version"
register: "docker_compose_version"
- debug:
var: "docker_compose_version.stdout"
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
- name: "Add Go binaries to PATH"
lineinfile:
path: "~/.profile"
line: "export PATH=$PATH:/usr/local/go/bin"
create: "yes"
line: "{{ item }}"
state: "present"
loop: "{{ ['export GOROOT=/usr/local/go', 'export GOPATH=$HOME/go', 'export PATH=$GOPATH/bin:$GOROOT/bin:$PATH'] }}"

- name: "Source ~/.profile"
shell: "source ~/.profile; go version"
Expand Down
29 changes: 29 additions & 0 deletions scripts/ansible/install-nodejs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
- name: "Install Node.js and npm"
hosts: "web"
gather_facts: "no"

tasks:
- name: "Update apt cache"
apt:
update_cache: "yes"

- name: "Install Node.js and npm"
apt:
name:
- "nodejs"
- "npm"
state: "present"

- name: "Get Node.js version"
shell: "node -v"
register: "node_version"
- debug:
var: "node_version.stdout"


- name: "Get npm version"
shell: "npm -v"
register: "npm_version"
- debug:
var: "npm_version.stdout"
22 changes: 0 additions & 22 deletions scripts/ansible/make.yml

This file was deleted.

0 comments on commit 54a4fdd

Please sign in to comment.