From 08dfe0bc61b21a2d31a7942244cc832dc028e34b Mon Sep 17 00:00:00 2001 From: Ondrej Kokes Date: Mon, 28 Feb 2022 09:06:29 +0100 Subject: [PATCH 1/3] prvni draft ansible playbooku (jeste cron a docku) --- ansible-bootstrap.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 ansible-bootstrap.yml diff --git a/ansible-bootstrap.yml b/ansible-bootstrap.yml new file mode 100644 index 00000000..e05ed711 --- /dev/null +++ b/ansible-bootstrap.yml @@ -0,0 +1,30 @@ +# TODO: apt update? + +- name: setup the server + hosts: all + become: yes + tasks: + - name: update apt + ansible.builtin.apt: + update_cache: yes + cache_valid_time: 3600 + - name: install base Python distro + ansible.builtin.apt: + name: + - python3-pip + - python3-venv + +- name: setup venv and code + hosts: all + tasks: + - name: create virtualenv + ansible.builtin.command: + cmd: python3 -m venv .venv + creates: ~/.venv/bin/activate + - name: clone od repo + ansible.builtin.git: + repo: 'https://github.com/kokes/od' + dest: '~/od/' + clone: yes + single_branch: yes + version: main \ No newline at end of file From 63b7d70738e76b58c8707ed707319aa93494dca1 Mon Sep 17 00:00:00 2001 From: Ondrej Kokes Date: Mon, 28 Feb 2022 09:46:45 +0100 Subject: [PATCH 2/3] pg bootstrap --- ansible-bootstrap.yml | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/ansible-bootstrap.yml b/ansible-bootstrap.yml index e05ed711..6fb1c16c 100644 --- a/ansible-bootstrap.yml +++ b/ansible-bootstrap.yml @@ -13,18 +13,47 @@ name: - python3-pip - python3-venv + - name: install postgres + ansible.builtin.apt: + name: + - postgresql - name: setup venv and code hosts: all tasks: - - name: create virtualenv - ansible.builtin.command: - cmd: python3 -m venv .venv - creates: ~/.venv/bin/activate - name: clone od repo ansible.builtin.git: repo: 'https://github.com/kokes/od' - dest: '~/od/' + dest: '~/od/' # TODO: udelat z toho promennou clone: yes single_branch: yes - version: main \ No newline at end of file + version: main + - name: create virtualenv + ansible.builtin.command: + cmd: python3 -m venv .venv + chdir: ~/od/ + creates: ~/od/.venv/bin/activate + - name: install dependencies + # TODO: tohle bezi vzdy, se mi uplne nelibi + ansible.builtin.command: + cmd: ./.venv/bin/python -m pip install -r requirements.txt + chdir: ~/od/ + +# TODO: use a dedicated postgres role? +- name: create postgres db + hosts: all + become: yes + become_user: postgres + # TODO: `creates` pro tyhle tasky + tasks: + - name: setup user + ansible.builtin.command: + cmd: createuser ubuntu # TODO: promennou? + - name: create db + ansible.builtin.command: + cmd: createdb + +# - name: setup crons and such +# hosts: all +# tasks: +# - name: foo \ No newline at end of file From 068d76e98ef65e07bedcf99957a257ea1d3762ad Mon Sep 17 00:00:00 2001 From: Ondrej Kokes Date: Tue, 1 Mar 2022 10:25:03 +0100 Subject: [PATCH 3/3] wip --- ansible-bootstrap.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ansible-bootstrap.yml b/ansible-bootstrap.yml index 6fb1c16c..8efac25e 100644 --- a/ansible-bootstrap.yml +++ b/ansible-bootstrap.yml @@ -20,6 +20,7 @@ - name: setup venv and code hosts: all + gather_facts: false tasks: - name: clone od repo ansible.builtin.git: @@ -42,6 +43,7 @@ # TODO: use a dedicated postgres role? - name: create postgres db hosts: all + gather_facts: false become: yes become_user: postgres # TODO: `creates` pro tyhle tasky @@ -51,7 +53,7 @@ cmd: createuser ubuntu # TODO: promennou? - name: create db ansible.builtin.command: - cmd: createdb + cmd: createdb od # - name: setup crons and such # hosts: all