From 1e3e08b555af07ee4bf08b24d7b616143cf55a72 Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Mon, 19 Dec 2022 23:46:55 +0100 Subject: [PATCH] change variable --- inventory/host_vars/vps-host | 23 ++++++++++++----------- roles/deploy-web/tasks/deploy.yml | 27 ++++++++++++++------------- roles/deploy-web/tasks/destroy.yml | 10 +++++----- 3 files changed, 31 insertions(+), 29 deletions(-) diff --git a/inventory/host_vars/vps-host b/inventory/host_vars/vps-host index 3284deb..bd6ad10 100644 --- a/inventory/host_vars/vps-host +++ b/inventory/host_vars/vps-host @@ -1,12 +1,13 @@ $ANSIBLE_VAULT;1.1;AES256 -39343765633561393532373365313435383266313661663666643731356262633063643761633662 -3732306165616334373164303133336565343939643939330a353635613432313230356237306330 -39653132363064323961396162383563303334323930396338303566656632663666626337303662 -3338323062366239650a366338346462363565343735643930663338376537343962656534393732 -36363331353832626261656461636636613332643964336634353963313332356366663739363238 -65356661333639313666383931323363306165643038653164313939376637386666303661363737 -63386466373961623736656635633433333461353435646336323738636334353337313535333663 -30356236363561613630666465663464383965376162653164613431616336336466316330376430 -61396238626364656461666163623234316533663234613931623138376564303236633163626337 -66303734346561613636353239646461626439303537393265353532323233656536663362636164 -656534363934393039623035656335353839 +31613733363838323034373330363534363737373764653261366361376236333563646233336163 +3465613439303661373361663964343338376261323566640a373837646263383965343831306438 +62643130316366653865643438343630306439326431396339623635363630343164366530373464 +3736333430616261320a376138643533393365326330316634393437393763363566373239626532 +61323331633030316438313563616164366335643331393536666134653339363639393033633935 +34616439383165633035373764386439653336383837653933356439363866373432303364353864 +65653439353538376633653666643765333730363634383361346137623432343939346266383362 +34373638356462353066623930653766353331353936656133636230613264353933616161643139 +64626639343863373933633963633861333739396361323636303535376336663832326261383535 +64623266653562393664323330366564643437383532663163386535643835653362346339653236 +35656339396633356530333266666439373561356133343164643138353230353334373731323861 +33393432363632653333 diff --git a/roles/deploy-web/tasks/deploy.yml b/roles/deploy-web/tasks/deploy.yml index cee6220..3cafaa2 100644 --- a/roles/deploy-web/tasks/deploy.yml +++ b/roles/deploy-web/tasks/deploy.yml @@ -3,42 +3,43 @@ - name: "git archive {{ item }}" local_action: module: git - repo: "https://{{ git_username | urlencode }}:{{ git_password | urlencode }}@git.valczeryba.ovh/v4l3n71n/{{ item }}.git" + repo: "https://{{ git_username | urlencode }}:{{ git_password | urlencode }}@git.valczeryba.ovh/v4l3n71n/{{ item.name }}.git" dest: "/home/valentin/src/" - archive: "/tmp/{{ item }}.tar.gz" + archive: "/tmp/{{ item.name }}.tar.gz" force: yes update: yes + when: "item.name is defined" with_items: - - "{{ project_name }}" - when: "project_name is defined" + - "{{ project }}" + -- name: "Create directory {{ item }}" +- name: "Create directory " file: - path: "/var/www/{{ item }}" + path: "/var/www/{{ item.name }}" state: directory owner: www-data group: www-data mode: '500' + when: "item.name is defined" with_items: - - "{{ project_name }}" - when: "project_name is defined" + - "{{ project }}" vars: ansible_become: yes ansible_become_method: sudo ansible_become_password: "{{ sudo_password }}" -- name: "Extract repo {{ item }}" +- name: "Extract repo " unarchive: - src: "/tmp/{{ item }}.tar.gz" - dest: "/var/www/{{ item }}" + src: "/tmp/{{ item.name }}.tar.gz" + dest: "/var/www/{{ item.name }}" owner: www-data group: www-data mode: '500' + when: "item.name is defined" with_items: - - "{{ project_name }}" - when: "project_name is defined" + - "{{ project }}" vars: ansible_become: yes ansible_become_method: sudo diff --git a/roles/deploy-web/tasks/destroy.yml b/roles/deploy-web/tasks/destroy.yml index 1479bfa..6907e6f 100644 --- a/roles/deploy-web/tasks/destroy.yml +++ b/roles/deploy-web/tasks/destroy.yml @@ -1,10 +1,10 @@ - name: "Remove all directories" file: - path: "/var/www/{{ item }}" + path: "/var/www/{{ item.name }}" state: absent + when: "item.name is defined and project_name is not defined" with_items: - - "{{ project_name }}" - when: "project_name is defined and project is not defined" + - "{{ project }}" vars: ansible_become: yes ansible_become_method: sudo @@ -12,9 +12,9 @@ - name: "Remove single directory" file: - path: "/var/www/{{ project }}" + path: "/var/www/{{ project_name }}" state: absent - when: "project is defined" + when: "project_name is defined" vars: ansible_become: yes ansible_become_method: sudo