-
Notifications
You must be signed in to change notification settings - Fork 43
My pull request #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
My pull request #10
Changes from all commits
627358b
ef69f4b
5b4443e
3014383
7f584ed
a6caedd
e4c0d27
794a042
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| .idea | ||
| .idea | ||
| .vscode |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| [defaults] | ||
| host_key_checking = False | ||
| inventory = inventory.ini |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| - hosts: server | ||
| become: yes | ||
| become_method: sudo | ||
|
|
||
|
|
||
| tasks: | ||
|
|
||
| - docker_host_info: | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. для каждой таски можно добавить name и написать небольшое описание что она делает. считай сразу пишешь документацию |
||
| images: yes | ||
| containers: yes | ||
| register: docker_objects | ||
|
|
||
| - docker_container: | ||
| name: "{{ item.Id }}" | ||
| state: absent | ||
| loop: "{{ docker_objects.containers }}" | ||
| loop_control: | ||
| label: "{{ item.Id }}" | ||
|
|
||
| - docker_image: | ||
| name: item.RepoTags | first | ||
| state: absent | ||
| force_absent: yes | ||
| loop: "{{ docker_objects.images }}" | ||
| loop_control: | ||
| label: "{{ item.RepoTags | first }}" | ||
|
|
||
|
|
||
| - hosts: client | ||
| become: yes | ||
| become_method: sudo | ||
|
|
||
| tasks: | ||
|
|
||
| - docker_host_info: | ||
| images: yes | ||
| containers: yes | ||
| register: docker_objects | ||
|
|
||
| - docker_container: | ||
| name: "{{ item.Id }}" | ||
| state: absent | ||
| loop: "{{ docker_objects.containers }}" | ||
| loop_control: | ||
| label: "{{ item.Id }}" | ||
|
|
||
| - docker_image: | ||
| name: item.RepoTags | first | ||
| state: absent | ||
| force_absent: yes | ||
| loop: "{{ docker_objects.images }}" | ||
| loop_control: | ||
| label: "{{ item.RepoTags | first }}" | ||
|
|
||
|
|
||
| - hosts: gateway | ||
| become: yes | ||
| become_method: sudo | ||
|
|
||
| tasks: | ||
|
|
||
| - docker_host_info: | ||
| images: yes | ||
| containers: yes | ||
| register: docker_objects | ||
|
|
||
| - docker_container: | ||
| name: "{{ item.Id }}" | ||
| state: absent | ||
| loop: "{{ docker_objects.containers }}" | ||
| loop_control: | ||
| label: "{{ item.Id }}" | ||
|
|
||
| - docker_image: | ||
| name: item.RepoTags | first | ||
| state: absent | ||
| force_absent: yes | ||
| loop: "{{ docker_objects.images }}" | ||
| loop_control: | ||
| label: "{{ item.RepoTags | first }}" | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,192 @@ | ||
| - hosts: gateway | ||
| become: yes | ||
| become_method: sudo | ||
| vars: | ||
| packages: | ||
| - net-tools | ||
| - docker.io | ||
| - docker-compose | ||
|
|
||
|
|
||
| tasks: | ||
|
|
||
| - name: installing packages | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. везде добавь name с описанием таски |
||
| ansible.builtin.apt: | ||
| pkg: "{{packages}}" | ||
| state: latest | ||
|
|
||
| # - name: import netplan cfg for gateway | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. такие рудементы не стоит хранить в публичной репе |
||
| # ansible.builtin.template: | ||
| # src: "{{gateway_net_src}}" | ||
| # dest: "{{gateway_net_dest}}" | ||
| # owner: root | ||
| # group: root | ||
| # mode: '0644' | ||
|
|
||
| - docker_host_info: | ||
| images: yes | ||
| containers: yes | ||
| register: docker_objects | ||
|
|
||
| - docker_container: | ||
| name: "{{ item.Id }}" | ||
| state: absent | ||
| loop: "{{ docker_objects.containers }}" | ||
| loop_control: | ||
| label: "{{ item.Id }}" | ||
|
|
||
| - docker_image: | ||
| name: item.RepoTags | first | ||
| state: absent | ||
| force_absent: yes | ||
| loop: "{{ docker_objects.images }}" | ||
| loop_control: | ||
| label: "{{ item.RepoTags | first }}" | ||
|
|
||
|
|
||
| - name: copying broker | ||
| ansible.builtin.copy: | ||
| src: "{{broker_src}}" | ||
| dest: "{{broker_dest}}" | ||
| owner: root | ||
| group: root | ||
| mode: '0644' | ||
|
|
||
| - name: starting mqtt broker | ||
| docker_container: | ||
| name: broker | ||
| image: eclipse-mosquitto | ||
| state: started | ||
| ports: | ||
| - "1883:1883" | ||
| volumes: | ||
| - "{{mosquitto_src}}" | ||
|
|
||
|
|
||
| - hosts: server | ||
| become: yes | ||
| become_method: sudo | ||
| vars: | ||
| packages: | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. все одинаковые таски просятся быть оформленными в роли. На самом деле на всех тачках ты делаешь одни и те же действия - ставишь докер и докер композ, запускаешь docker compose up. просто разные файлики и параметры по сути пишется одна две роли и инклудятся в разные тачки. сейчас у тебя много дублирования |
||
| - net-tools | ||
| - python3-pip | ||
| - docker.io | ||
| - docker-compose | ||
|
|
||
| tasks: | ||
|
|
||
| - name: installing pkg | ||
| ansible.builtin.apt: | ||
| pkg: "{{ packages }}" | ||
| state: latest | ||
|
|
||
| - name: copying grafana and telegraf | ||
| ansible.builtin.copy: | ||
| src: "{{server_infra}}" | ||
| dest: "{{docker_src_server}}" | ||
| owner: "{{server_user}}" | ||
| group: "{{server_user}}" | ||
| mode: '0644' | ||
|
|
||
| # - name: restarting net adapter | ||
| # shell: ifconfig enp0s8 down | ||
|
|
||
| # - name: Update netplan cfg on server | ||
| # ansible.builtin.template: | ||
| # src: "{{server_net_src}}" | ||
| # dest: "{{server_net_dest}}" | ||
| # owner: root | ||
| # group: root | ||
| # mode: '0644' | ||
|
|
||
| - docker_host_info: | ||
| images: yes | ||
| containers: yes | ||
| register: docker_objects | ||
|
|
||
| - docker_container: | ||
| name: "{{ item.Id }}" | ||
| state: absent | ||
| loop: "{{ docker_objects.containers }}" | ||
| loop_control: | ||
| label: "{{ item.Id }}" | ||
|
|
||
| - docker_image: | ||
| name: item.RepoTags | first | ||
| state: absent | ||
| force_absent: yes | ||
| loop: "{{ docker_objects.images }}" | ||
| loop_control: | ||
| label: "{{ item.RepoTags | first }}" | ||
|
|
||
| - name: docker-compose up on server | ||
| docker_compose: | ||
| project_src: "{{docker_src_server}}" | ||
|
|
||
| # - name: netplan apply | ||
| # shell: netplan apply | ||
|
|
||
|
|
||
| - hosts: client | ||
| become: yes | ||
| become_method: sudo | ||
| vars: | ||
| packages: | ||
| - net-tools | ||
| - python3-pip | ||
| - docker.io | ||
| - docker-compose | ||
|
|
||
| tasks: | ||
|
|
||
|
|
||
| - name: installing pkg | ||
| ansible.builtin.apt: | ||
| pkg: "{{ packages }}" | ||
| state: latest | ||
|
|
||
| - name: copying simulator | ||
| ansible.builtin.copy: | ||
| src: "{{simulator_src}}" | ||
| dest: "{{simulator_dest}}" | ||
| owner: "{{client_user}}" | ||
| group: "{{client_user}}" | ||
| mode: '0644' | ||
|
|
||
| # - name: restarting net adapter | ||
| # shell: ifconfig enp0s8 down | ||
|
|
||
| # - name: cfg for client host | ||
| # ansible.builtin.template: | ||
| # src: "{{client_cfg_src}}" | ||
| # dest: "{{client_cfg_dest}}" | ||
| # owner: root | ||
| # group: root | ||
| # mode: '0644' | ||
|
|
||
| - docker_host_info: | ||
| images: yes | ||
| containers: yes | ||
| register: docker_objects | ||
|
|
||
| - docker_container: | ||
| name: "{{ item.Id }}" | ||
| state: absent | ||
| loop: "{{ docker_objects.containers }}" | ||
| loop_control: | ||
| label: "{{ item.Id }}" | ||
|
|
||
| - docker_image: | ||
| name: item.RepoTags | first | ||
| state: absent | ||
| force_absent: yes | ||
| loop: "{{ docker_objects.images }}" | ||
| loop_control: | ||
| label: "{{ item.RepoTags | first }}" | ||
|
|
||
| - name: docker-compose up on client | ||
| docker_compose: | ||
| project_src: "{{docker_src_client}}" | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| client_cfg_src: vms/client/00-installer-config.yaml | ||
| client_cfg_dest: /etc/netplan/00-installer-config.yaml | ||
| simulator_src: vms/client/simulator/ | ||
| simulator_dest: /home/armitage/remote | ||
| client_user: armitage | ||
| docker_src_client: /home/armitage/remote |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| --- | ||
| gateway_net_src: vms/gateway/00-installer-config.yaml | ||
| gateway_net_dest: /etc/netplan/00-installer-config.yaml | ||
| gateway_rules_src: vms/gateway/rules.v4 | ||
| gateway_rules_dest: /etc/iptables/rules.v4 | ||
| broker_src: vms/gateway/ | ||
| broker_dest: /home/armitage/remote | ||
| gateway_user: armitage | ||
| mosquitto_src: /home/armitage/remote/mosquitto:/mosquitto/config |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| server_net_src: vms/server/00-installer-config.yaml | ||
| server_net_dest: /etc/netplan/00-installer-config.yaml | ||
| server_infra: vms/server/infra/ | ||
| server_user: armitage | ||
| docker_src_server: /home/armitage/remote |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| [cluster:vars] | ||
| ansible_ssh_pass = '{{my_ssh_pass}}' | ||
| ansible_sudo_pass= '{{my_cluster_sudo_pass}}' | ||
|
|
||
| [cluster] | ||
| server | ||
| gateway | ||
| client | ||
|
|
||
| [server_host:vars] | ||
| ansible_ssh_pass = '{{my_ssh_pass}}' | ||
| ansible_sudo_pass= '{{my_cluster_sudo_pass}}' | ||
| [server_host] | ||
| server ansible_host=192.168.0.167 ansible_ssh_user=armitage ansible_become=true StrictHostKeyChecking=no | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ansible_ssh_pass |
||
|
|
||
| [gateway_host:vars] | ||
| ansible_ssh_pass = '{{my_ssh_pass}}' | ||
| ansible_sudo_pass= '{{my_cluster_sudo_pass}}' | ||
| [gateway_host] | ||
| gateway ansible_host=192.168.0.144 ansible_ssh_user=armitage ansible_become=true | ||
|
|
||
| [client_host:vars] | ||
| ansible_ssh_pass = '{{my_ssh_pass}}' | ||
| ansible_sudo_pass= '{{my_cluster_sudo_pass}}' | ||
| [client_host] | ||
| client ansible_host=192.168.0.168 ansible_ssh_user=armitage ansible_become=true | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| network: | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. это стоит оформить в виде темплейта с конфигурируемыми адресами |
||
| ethernets: | ||
| enp0s3: | ||
| dhcp4: true | ||
| enp0s8: | ||
| dhcp4: no | ||
| addresses: [ 192.168.5.10/24 ] | ||
| gateway4: 192.168.5.1 | ||
| version: 2 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| SIM_HOST_IP=192.168.0.144 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| version: "3" | ||
|
|
||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. композ файлы можно также оформить в виде темплейта |
||
| services: | ||
| temp_sensor: | ||
| image: wuwun9/simulator | ||
| environment: | ||
| - SIM_HOST=$SIM_HOST_IP | ||
| - SIM_NAME=SIM_TEMPERATURE | ||
| - SIM_PERIOD=5 | ||
| - SIM_TYPE=temperature | ||
| pressure_sensor: | ||
| image: wuwun9/simulator | ||
| environment: | ||
| - SIM_HOST=$SIM_HOST_IP | ||
| - SIM_NAME=SIM_PRESSURE | ||
| - SIM_PERIOD=10 | ||
| - SIM_TYPE=pressure | ||
| current_sensor: | ||
| image: wuwun9/simulator | ||
| environment: | ||
| - SIM_HOST=$SIM_HOST_IP | ||
| - SIM_NAME=SIM_CURRENT | ||
| - SIM_PERIOD=1 | ||
| - SIM_TYPE=current | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| network: | ||
| ethernets: | ||
| enp0s3: | ||
| dhcp4: true | ||
| enp0s8: | ||
| dhcp4: no | ||
| addresses: [ 192.168.7.1/24 ] | ||
| enp0s9: | ||
| dhcp4: no | ||
| addresses: [ 192.168.5.1/24 ] | ||
| version: 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
нейминг файлов отличается. придерживайся одного принципа. либо через - либо через _