Skip to content

Instantly share code, notes, and snippets.

@naa0yama
Created June 6, 2020 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naa0yama/8833a43faf8c351d33b67cd752bb7884 to your computer and use it in GitHub Desktop.
Save naa0yama/8833a43faf8c351d33b67cd752bb7884 to your computer and use it in GitHub Desktop.
Cumulus の絵r−あ

dir

.
├── Dockerfile
├── ansible.cfg
├── inventory
├── known_hosts
├── playbook
├── poetry.lock
├── pyproject.toml
├── requirements.yml
├── roles
│   ├── cumulus
│   │   ├── bgp
│   │   │   └── tasks
│   │   │       └── main.yml
│   │   ├── edge
│   │   │   └── interfaces
│   │   │       ├── handlers
│   │   │       │   └── main.yml
│   │   │       ├── tasks
│   │   │       │   └── main.yml
│   │   │       └── templates
│   │   │           └── interfaces.j2
├── ssh_config

roles/cumulus/edge/interfaces/handlers/main.yml

# ansible-configured
- name: apply interface config
  systemd:
    state: restarted
    name: networking
#- name: apply interface config reboot
#  reboot:
#    reboot_timeout: 300

roles/cumulus/edge/interfaces/tasks/main.yml

---
# ansible-configured
- name: "generate interfaces"
  template:
    src: "interfaces.j2"
    #dest: "/etc/network/interfaces"
    dest: "~/interfaces"
  notify: apply interface config
  #delegate_to: localhost

roles/wireguard/templates/wg.conf.j2

#jinja2: lstrip_blocks: "true", trim_blocks: "true"
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*.intf

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0
    address 192.0.2.1/24

ansible-playbook run

$ ansible-playbook -i inventory/cumulus.yml playbook/edge.yml

PLAY [edge] **********************************************************************************************************

TASK [Gathering Facts] ***********************************************************************************************
[WARNING]: Platform linux on host edge02 is using the discovered Python interpreter at /usr/bin/python, but future
installation of another Python interpreter could change this. See
https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information.
ok: [edge02]

TASK [cumulus/edge/interfaces : generate interfaces] *****************************************************************
changed: [edge02]

RUNNING HANDLER [cumulus/edge/interfaces : apply interface config] ***************************************************
fatal: [edge02]: FAILED! => {"msg": "Failed to connect to the host via ssh: Connection timed out during banner exchange\r\nConnection to 10.2.21.65 port 22 timed out"}

NO MORE HOSTS LEFT ***************************************************************************************************

PLAY RECAP ***********************************************************************************************************
edge02                     : ok=2    changed=1    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment