From 66bc8e2256ff411f8ab768fea1446e7dd23dd38b Mon Sep 17 00:00:00 2001 From: surtur Date: Mon, 9 Aug 2021 23:16:51 +0200 Subject: [PATCH] add ansible "sayhi" --- .ansible/ansible.cfg | 14 ++++++++++++++ .ansible/inventory | 3 +++ .ansible/playbooks/host_vars/dotya.ml.yml | 1 + .ansible/playbooks/playbook.yml | 7 +++++++ .ansible/roles/sayhi/README.md | 9 +++++++++ .ansible/roles/sayhi/defaults/main.yml | 1 + .ansible/roles/sayhi/tasks/main.yml | 9 +++++++++ .ansible/roles/sayhi/vars/main.yml | 1 + .drone.yml | 22 +++++++++++++++++++++- 9 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 .ansible/ansible.cfg create mode 100644 .ansible/inventory create mode 100644 .ansible/playbooks/host_vars/dotya.ml.yml create mode 100644 .ansible/playbooks/playbook.yml create mode 100644 .ansible/roles/sayhi/README.md create mode 100644 .ansible/roles/sayhi/defaults/main.yml create mode 100644 .ansible/roles/sayhi/tasks/main.yml create mode 100644 .ansible/roles/sayhi/vars/main.yml diff --git a/.ansible/ansible.cfg b/.ansible/ansible.cfg new file mode 100644 index 0000000..bdffeee --- /dev/null +++ b/.ansible/ansible.cfg @@ -0,0 +1,14 @@ +[defaults] +inventory = inventory +remote_tmp = $HOME/.ansible/tmp +remote_user = root +nocows = 1 +roles_path = roles +retry_files_enabled = False +max_diff_size = 250000 + +[ssh_connection] +pipelining = True +scp_if_ssh = True +retries = 7 + diff --git a/.ansible/inventory b/.ansible/inventory new file mode 100644 index 0000000..c3801f9 --- /dev/null +++ b/.ansible/inventory @@ -0,0 +1,3 @@ +[testtgt] +dotya.ml + diff --git a/.ansible/playbooks/host_vars/dotya.ml.yml b/.ansible/playbooks/host_vars/dotya.ml.yml new file mode 100644 index 0000000..ed97d53 --- /dev/null +++ b/.ansible/playbooks/host_vars/dotya.ml.yml @@ -0,0 +1 @@ +--- diff --git a/.ansible/playbooks/playbook.yml b/.ansible/playbooks/playbook.yml new file mode 100644 index 0000000..b618855 --- /dev/null +++ b/.ansible/playbooks/playbook.yml @@ -0,0 +1,7 @@ +--- +- hosts: testtgt + become: true + become_user: root + become_method: sudo + roles: + - { role: sayhi } diff --git a/.ansible/roles/sayhi/README.md b/.ansible/roles/sayhi/README.md new file mode 100644 index 0000000..5c00ce8 --- /dev/null +++ b/.ansible/roles/sayhi/README.md @@ -0,0 +1,9 @@ +# sayhi +this role is used to say hi (create test files) + +## License +GPLv3 + +## Author +wanderer@git.dotya.ml + diff --git a/.ansible/roles/sayhi/defaults/main.yml b/.ansible/roles/sayhi/defaults/main.yml new file mode 100644 index 0000000..ed97d53 --- /dev/null +++ b/.ansible/roles/sayhi/defaults/main.yml @@ -0,0 +1 @@ +--- diff --git a/.ansible/roles/sayhi/tasks/main.yml b/.ansible/roles/sayhi/tasks/main.yml new file mode 100644 index 0000000..940f12f --- /dev/null +++ b/.ansible/roles/sayhi/tasks/main.yml @@ -0,0 +1,9 @@ +--- +- name: verify files are not present + file: + path: "/tmp/{{item}}" + state: absent + mode: 0755 + with_items: + - "{{additional_var}}" + - "{{another_var}}" diff --git a/.ansible/roles/sayhi/vars/main.yml b/.ansible/roles/sayhi/vars/main.yml new file mode 100644 index 0000000..ed97d53 --- /dev/null +++ b/.ansible/roles/sayhi/vars/main.yml @@ -0,0 +1 @@ +--- diff --git a/.drone.yml b/.drone.yml index b3b8af8..7a8e166 100644 --- a/.drone.yml +++ b/.drone.yml @@ -33,4 +33,24 @@ steps: - echo $PATH - echo $SHELL - /usr/local/bin/giteaupdater - - ansible --version + + - name: ansible - sayhi + image: plugins/ansible:3.0.0 + environment: + ANSIBLE_CONFIG: .ansible/ansible.cfg + DEFAULT_REMOTE_USER: + from_secret: username + settings: + playbook: .ansible/playbooks/playbook.yml + inventory: .ansible/inventory + extra_vars: + 'additional_var=footestpls,another_var=bartest' + ssh_extra_args: "'-o StrictHostKeyChecking=no'" + private_key: + from_secret: ssh-key + verbose: 2 + user: + from_secret: username + when: + event: + - push