From 01e731af609208790f02c9d9a18ab95f0ba1248a Mon Sep 17 00:00:00 2001 From: Gorka Benguria <gorka.benguria@tecnalia.com> Date: Mon, 27 Feb 2023 02:21:53 +0100 Subject: [PATCH] adjusted version --- ansible.cfg | 7 ------- ansible_requirements.yml | 2 +- config.yaml | 12 ++++++++++++ hosts.yaml | 4 ---- install_playbook_requirements.sh | 33 -------------------------------- inventory.j2 | 9 +++++++++ inventory.txt | 2 ++ site.yaml => main.yml | 18 ++++++++++++++--- run-playbook.sh | 33 -------------------------------- site_requirements.yaml | 9 --------- ssh_key.j2 | 27 ++++++++++++++++++++++++++ vars/main.yaml | 8 ++++++-- 12 files changed, 72 insertions(+), 92 deletions(-) delete mode 100644 ansible.cfg create mode 100644 config.yaml delete mode 100644 hosts.yaml delete mode 100644 install_playbook_requirements.sh create mode 100644 inventory.j2 create mode 100644 inventory.txt rename site.yaml => main.yml (63%) delete mode 100644 run-playbook.sh delete mode 100644 site_requirements.yaml create mode 100644 ssh_key.j2 diff --git a/ansible.cfg b/ansible.cfg deleted file mode 100644 index 660a5eb..0000000 --- a/ansible.cfg +++ /dev/null @@ -1,7 +0,0 @@ -# https://docs.ansible.com/ansible/latest/reference_appendices/config.html -[defaults] -host_key_checking = False -inventory = {{CWD}}/hosts.yaml ; This points to the file that lists your hosts -remote_user = esilab -deprecation_warnings=False ; to remove the python version depretation warning -display_skipped_hosts = no \ No newline at end of file diff --git a/ansible_requirements.yml b/ansible_requirements.yml index 9e6f831..b09ccc3 100644 --- a/ansible_requirements.yml +++ b/ansible_requirements.yml @@ -5,4 +5,4 @@ roles: - name: dj-wasabi.telegraf src: https://github.com/dj-wasabi/ansible-telegraf.git scm: git - version: 0.13.2 + version: 0.14.0 diff --git a/config.yaml b/config.yaml new file mode 100644 index 0000000..efc897f --- /dev/null +++ b/config.yaml @@ -0,0 +1,12 @@ +--- +input: + - INFLUXDB_BUCKET + - INFLUXDB_TOKEN + - INFLUXDB_ORG + - INFLUXDB_ADDR + - DEPLOYMENT_ID + # - instance_ip_vm1 + # - instance_server_private_key_user1 +output: [] +engine: ansible +... \ No newline at end of file diff --git a/hosts.yaml b/hosts.yaml deleted file mode 100644 index 292422c..0000000 --- a/hosts.yaml +++ /dev/null @@ -1,4 +0,0 @@ -all: - hosts: - localhost: - ansible_connection: local diff --git a/install_playbook_requirements.sh b/install_playbook_requirements.sh deleted file mode 100644 index 843bf3b..0000000 --- a/install_playbook_requirements.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash -set -e - -SCRIPT_DIR=$(dirname "$0") - -# to avoid the being run in a world writable directory we explicitly assign the ANSIBLE_CONFIG variable -if [[ -f ./ansible.cfg ]] -then - export ANSIBLE_CONFIG=./ansible.cfg -else - if [[ -f $SCRIPT_DIR/ansible.cfg ]] - then - export ANSIBLE_CONFIG=$SCRIPT_DIR/ansible.cfg - fi -fi - -if [[ -z "$ANSIBLE_CONFIG" ]] -then - echo ANSIBLE_CONFIG to assigned using default https://docs.ansible.com/ansible/latest/reference_appendices/config.html -else - echo ANSIBLE_CONFIG=$ANSIBLE_CONFIG -fi - -if [[ -z "$1" ]] -then - # echo without params - echo ansible-playbook $SCRIPT_DIR/site_requirements.yaml - ansible-playbook $SCRIPT_DIR/site_requirements.yaml -else - # echo with params - echo ansible-playbook $SCRIPT_DIR/site_requirements.yaml --extra-vars "$1" - ansible-playbook $SCRIPT_DIR/site_requirements.yaml --extra-vars "$1" -fi diff --git a/inventory.j2 b/inventory.j2 new file mode 100644 index 0000000..6fd79f1 --- /dev/null +++ b/inventory.j2 @@ -0,0 +1,9 @@ + + +[servers_for_piacere_monitoring] +demo-server-for-agents-at-iem + +[servers_for_piacere_monitoring:vars] +ansible_connection=ssh +ansible_user=ubuntu +ansible_ssh_private_key_file=ssh_key diff --git a/inventory.txt b/inventory.txt new file mode 100644 index 0000000..4c1b112 --- /dev/null +++ b/inventory.txt @@ -0,0 +1,2 @@ +[docker] +localhost \ No newline at end of file diff --git a/site.yaml b/main.yml similarity index 63% rename from site.yaml rename to main.yml index b754348..7c38456 100644 --- a/site.yaml +++ b/main.yml @@ -1,3 +1,14 @@ +--- +- hosts: localhost + tasks: + - name: print disclamer + debug: + msg: this can also be done with "ansible-galaxy install -r requirements" + - name: install telegraf from galaxy + community.general.ansible_galaxy_install: + type: role + requirements_file: ansible_requirements.yml + - hosts: all pre_tasks: - name: Check parameters @@ -23,8 +34,9 @@ name: gnupg state: present become: true - vars_files: - vars/main.yaml - roles: - - dj-wasabi.telegraf + tasks: + - name: Install telegraf + ansible.builtin.include_role: + name: dj-wasabi.telegraf diff --git a/run-playbook.sh b/run-playbook.sh deleted file mode 100644 index f2bba22..0000000 --- a/run-playbook.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash -set -e - -SCRIPT_DIR=$(dirname "$0") - -# to avoid the being run in a world writable directory we explicitly assign the ANSIBLE_CONFIG variable -if [[ -f ./ansible.cfg ]] -then - export ANSIBLE_CONFIG=./ansible.cfg -else - if [[ -f $SCRIPT_DIR/ansible.cfg ]] - then - export ANSIBLE_CONFIG=$SCRIPT_DIR/ansible.cfg - fi -fi - -if [[ -z "$ANSIBLE_CONFIG" ]] -then - echo ANSIBLE_CONFIG to assigned using default https://docs.ansible.com/ansible/latest/reference_appendices/config.html -else - echo ANSIBLE_CONFIG=$ANSIBLE_CONFIG -fi - -if [[ -z "$1" ]] -then - # echo without params - echo ansible-playbook $SCRIPT_DIR/site.yaml - ansible-playbook $SCRIPT_DIR/site.yaml -else - # echo with params - echo ansible-playbook $SCRIPT_DIR/site.yaml --extra-vars "$1" - ansible-playbook $SCRIPT_DIR/site.yaml --extra-vars "$1" -fi diff --git a/site_requirements.yaml b/site_requirements.yaml deleted file mode 100644 index dd3702a..0000000 --- a/site_requirements.yaml +++ /dev/null @@ -1,9 +0,0 @@ -- hosts: localhost - tasks: - - name: print disclamer - debug: - msg: this can also be done with "ansible-galaxy install -r requirements" - - name: install telegraf from galaxy - community.general.ansible_galaxy_install: - type: role - requirements_file: ansible_requirements.yml diff --git a/ssh_key.j2 b/ssh_key.j2 new file mode 100644 index 0000000..86a197b --- /dev/null +++ b/ssh_key.j2 @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpAIBAAKCAQEA1FrTNE42EgZr9WJNMtvpKFHYhPUJ4lzEp83EM0jYY3TyjmIe +ThMuqMLAHCk22fl4a8PttucggJ5ZWKhcJh623/y8AybJcmqZgq9a41Q609dmirf0 +7frCl+6zL8Mqy2Le2BD4eRADcq11s8r8Ys6J+EBPHQgEnK9CeZLSc/WFRlVr4bOD +s0bEouDxjTAMYjYcpsCwqYgGdIXI9WWsnt3RvcEe8CaiTqoyDN8ZtgkG6MweSrTQ +js8ySHO6o25cOoF7aT9Ihhf32I+KUanNIOvk3RAw2z1FK5xkFbbqMggZqz7rJn3M +sn2dDiCQi2CWox2OYXV/jJKLC3UFuOX64fS9cwIDAQABAoIBAQCs69Tm1/Vx0ibh +aA4DJ06C1bsh8cP9v5soJgfp1xzWSGooBcA1xasOI6B6jhkrgNlNr/uIIEe4VLne +1yJKrGIwnUagrloGQMYGxDKXwYQx80p+FXRuwe7p96eUcjIL8tQSUCd1tdOI87VQ +FjBVaWiybfO+aUQQLytLgoK7iKfhb7vO+9F+ZK1iDjBDNxFuiOM5zoeWOI7boYkD +2yXIkwoBePS2rosbPLa649sVakKex2WhQdUFst4Zba2RhnWQBXUY44LvEK5TzScF +FyYphPOUSplbzzM2+fuOna91NIWmJyHmf15lj7X9kC66XFIZMlvapksB8stEpDiA +4al3IdBJAoGBAPPuM3xkr/kQYYn7E42fgpmINZ78V48gMLhpyUOabZtF8inMyMPB +q7kfHns8Vx0ET8grSNr3qwDDV82lwvGqRCFChASMdQRR9LanydkDSeqpuZyQtVlt +A/65YUdcNY7Vy+M+fRh5Srh/6qcO3beLeLWXbJ4RHBP/OEmHuF4mLfgVAoGBAN7c +qdxTOhXPvOU69Bs5rJdfo6qBI1Yg8MCGctsUwPFpw1kW773ROOPa6XI6D74Dsdg8 +ypZ+IC3pRVtx61Xi3NOwxWNTTG+dyUgTSFz+WKjywXZXeHIbWngiFqk8JFYQWPzk +6YaJk4tZhk2YuNNaCCYRgQqyWv8coEurRlMXZHlnAoGBALcJwdaQ0z8oXJimL4jw +7ZX5kIrpPWanuAdZUe4Jfj+qX8mf4fKKbCowQLYmlBOw/ZDtcfDlMYsUCdnFjZ+7 +rP3sJJYpM1F3khJRm3PdNOUCUMY8C+i7lejZADcE6SdyJFkztbjcowYI7nJHBHZL +ENvqcVW27wPOWlVKozz6lzn1AoGALVwmaoS6DtRwcwuzwZLUkR7TNhIAujgMKHN1 +DyhDOR+4tfpYI39hH+dfmnM83wTrfsKozUawkAepqToflySMo72X/2Zl6VXpMPVT +xjGyo/h87fRRvI/asxblG9702luLcTW6XjrEQBmhn0uVWtc5T15CsIWqxb/y1FPx +BVp+hcMCgYAlJXbjzjbbDoIOCsXPSPe9voBL8zVwp0aNuvQcuB/vCt1n1c1DWuPr +AGMy/fRwY0Znag+ODMuulm7RgXUQy6ifJHiz9cKVGg/mGifaJSjgC+1AI9HFlij3 +asM5CueU0gK974rDxQkwmIWpRH57+kf6s8tGDrPPvqX9S4p3oxFlTw== +-----END RSA PRIVATE KEY----- diff --git a/vars/main.yaml b/vars/main.yaml index 4434cb2..cef9f65 100644 --- a/vars/main.yaml +++ b/vars/main.yaml @@ -1,3 +1,9 @@ +pma_deployment_id: "{{ lookup('env', 'DEPLOYMENT_ID' ) }}" +pma_influxdb_bucket: "{{ lookup('env', 'INFLUXDB_BUCKET' ) }}" +pma_influxdb_token: "{{ lookup('env', 'INFLUXDB_TOKEN' ) }}" +pma_influxdb_org: "{{ lookup('env', 'INFLUXDB_ORG' ) }}" +pma_influxdb_addr: "{{ lookup('env', 'INFLUXDB_ADDR' ) }}" + telegraf_agent_package_state: latest telegraf_agent_output: @@ -19,5 +25,3 @@ telegraf_plugins_default: - plugin: processes - plugin: disk - plugin: net - - -- GitLab