Skip to content

Instantly share code, notes, and snippets.

@radut
Forked from lbragstad/bgmccollum-directions
Created August 19, 2023 00:46
Show Gist options
  • Save radut/a32f987214a5c2b11a928c5697cea69c to your computer and use it in GitHub Desktop.
Save radut/a32f987214a5c2b11a928c5697cea69c to your computer and use it in GitHub Desktop.

Revisions

  1. @lbragstad lbragstad revised this gist Aug 2, 2018. 1 changed file with 14 additions and 0 deletions.
    14 changes: 14 additions & 0 deletions network-create
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    root@aio1-utility-container-9cd95789:~# source ~/openrc
    root@aio1-utility-container-9cd95789:~# openstack network create \
    --share \
    --provider-network-type flat \
    --provider-physical-network flat \
    home
    root@aio1-utility-container-9cd95789:~# openstack subnet create \
    --subnet-range 192.168.1.0/24 \
    --allocation-pool start=192.168.1.200,end=192.168.1.249 \
    --dns-nameserver 192.168.1.1 \
    --gateway 192.168.1.1 \
    --no-dhcp \
    --network home \
    home-subnet
  2. @lbragstad lbragstad revised this gist Aug 2, 2018. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions list-server
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    root@aio1-utility-container-9cd95789:~# openstack server list --all-projects
    +--------------------------------------+----------+--------+--------------------+---------------------+-----------+
    | ID | Name | Status | Networks | Image | Flavor |
    +--------------------------------------+----------+--------+--------------------+---------------------+-----------+
    | 4437c978-5183-4389-bc58-a1785b146e49 | devstack | ACTIVE | home=192.168.1.202 | Ubuntu-18.04-x86_64 | m1.xlarge |
    +--------------------------------------+----------+--------+--------------------+---------------------+-----------+
  3. @lbragstad lbragstad revised this gist Aug 2, 2018. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions create-server
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    root@aio1-utility-container-9cd95789:~# openstack server create \
    --image Ubuntu-16.04-x86_64 \
    --flavor m1.large \
    --network home \
    --config-drive True \
    --key-name lbragstad \
    devstack
  4. @lbragstad lbragstad revised this gist Aug 2, 2018. 1 changed file with 13 additions and 0 deletions.
    13 changes: 13 additions & 0 deletions image-upload
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    root@aio1-utility-container-9cd95789:~# source openrc
    root@aio1-utility-container-9cd95789:~# wget http://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-disk1.img
    root@aio1-utility-container-9cd95789:~# wget http://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64.img
    root@aio1-utility-container-9cd95789:~# openstack image create \
    --container-format bare \
    --disk-format qcow2 \
    --file xenial-server-cloudimg-amd64-disk1.img \
    Ubuntu-16.04-x86_64
    root@aio1-utility-container-9cd95789:~# openstack image create \
    --container-format bare \
    --disk-format qcow2 \
    --file bionic-server-cloudimg-amd64.img \
    Ubuntu-18.04-x86_64
  5. @lbragstad lbragstad revised this gist Aug 2, 2018. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion update-iptables
    Original file line number Diff line number Diff line change
    @@ -1,2 +1,3 @@
    root@aio1:~# iptables -t nat -D POSTROUTING -o $PRIMARY_INTERFACE -j MASQUERADE
    root@aio1:~# iptables -D POSTROUTING -t mangle -p tcp --dport 22 -j CHECKSUM --checksum-fill
    root@aio1:~# iptables -D POSTROUTING -t mangle -p tcp --dport 22 -j CHECKSUM --checksum-fill
    root@aio1:~# reboot
  6. @lbragstad lbragstad revised this gist Aug 2, 2018. 2 changed files with 13 additions and 13 deletions.
    18 changes: 9 additions & 9 deletions deploy
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,9 @@
    # git clone https://git.openstack.org/openstack/openstack-ansible /opt/openstack-ansible
    # cd /opt/openstack-ansible
    # git checkout 17.0.7
    # scripts/bootstrap-ansible.sh
    # scripts/bootstrap-aio.sh
    # cd /opt/openstack-ansible/playbooks
    # openstack-ansible setup-hosts.yml
    # openstack-ansible setup-infrastructure.yml
    # openstack-ansible setup-openstack.yml
    root@aio1:~# git clone https://git.openstack.org/openstack/openstack-ansible /opt/openstack-ansible
    root@aio1:~# cd /opt/openstack-ansible
    root@aio1:~# git checkout 17.0.7
    root@aio1:~# scripts/bootstrap-ansible.sh
    root@aio1:~# scripts/bootstrap-aio.sh
    root@aio1:~# cd /opt/openstack-ansible/playbooks
    root@aio1:~# openstack-ansible setup-hosts.yml
    root@aio1:~# openstack-ansible setup-infrastructure.yml
    root@aio1:~# openstack-ansible setup-openstack.yml
    8 changes: 4 additions & 4 deletions interface-rename
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # ip link set eno1 down
    # ip link set eno1 name eth1
    # ip link set rename3 down
    # ip link set rename3 name eth0
    root@aio1:~# ip link set eno1 down
    root@aio1:~# ip link set eno1 name eth1
    root@aio1:~# ip link set rename3 down
    root@aio1:~# ip link set rename3 name eth0
  7. @lbragstad lbragstad renamed this gist Aug 2, 2018. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  8. @lbragstad lbragstad revised this gist Aug 2, 2018. 6 changed files with 99 additions and 0 deletions.
    12 changes: 12 additions & 0 deletions final-host-interfaces
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    # 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/*

    # The loopback network interface
    auto lo
    iface lo inet loopback

    # The primary network interface
    auto eth1
    iface eth1 inet manual
    4 changes: 4 additions & 0 deletions interfaces
    Original file line number Diff line number Diff line change
    @@ -10,3 +10,7 @@ iface lo inet loopback
    # The primary network interface
    auto eth1
    iface eth1 inet manual
    address 192.168.1.10
    netmask 255.255.255.0
    gateway 192.168.1.1
    dns-nameservers 192.168.1.1
    8 changes: 8 additions & 0 deletions network-cleanup
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    root@aio1:~# lxc-attach -n `lxc-ls -1 | grep util`
    root@aio1-utility-container-9cd95789:~# source ~/openrc
    root@aio1-utility-container-9cd95789:~# openstack router unset --external-gateway router
    root@aio1-utility-container-9cd95789:~# openstack router remove subnet router private-subnet
    root@aio1-utility-container-9cd95789:~# openstack router delete router
    root@aio1-utility-container-9cd95789:~# openstack network delete public
    root@aio1-utility-container-9cd95789:~# openstack network delete private
    root@aio1-utility-container-9cd95789:~# exit
    71 changes: 71 additions & 0 deletions osa-interfaces
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,71 @@
    ## The default networking requires several bridges. These bridges were named to be informative
    ## however they can be named what ever you like and is adaptable to any network infrastructure
    ## environment. This file serves as an example of how to setup basic networking and was ONLY
    ## built for the purpose of being an example and used expressly in the building of an ALL IN
    ## ONE development environment.

    auto br-mgmt
    iface br-mgmt inet static
    bridge_stp off
    bridge_waitport 0
    bridge_fd 0
    # Notice the bridge port is the vlan tagged interface
    bridge_ports none
    address 172.29.236.100
    netmask 255.255.252.0
    offload-sg off

    auto br-vxlan
    iface br-vxlan inet static
    bridge_stp off
    bridge_waitport 0
    bridge_fd 0
    bridge_ports none
    address 172.29.240.100
    netmask 255.255.252.0
    offload-sg off

    # To ensure ssh checksum is correct
    # up /sbin/iptables -A POSTROUTING -t mangle -p tcp --dport 22 -j CHECKSUM --checksum-fill
    # down /sbin/iptables -D POSTROUTING -t mangle -p tcp --dport 22 -j CHECKSUM --checksum-fill
    # To provide internet connectivity to instances
    # up /sbin/iptables -t nat -A POSTROUTING -o br-mgmt -j MASQUERADE
    # down /sbin/iptables -t nat -D POSTROUTING -o br-mgmt -j MASQUERADE

    auto br-storage
    iface br-storage inet static
    bridge_stp off
    bridge_waitport 0
    bridge_fd 0
    bridge_ports none
    address 172.29.244.100
    netmask 255.255.252.0
    offload-sg off

    auto br-vlan
    iface br-vlan inet static
    bridge_stp off
    bridge_waitport 0
    bridge_fd 0
    address 192.168.1.10
    gateway 192.168.1.1
    netmask 255.255.252.0
    offload-sg off
    # Create veth pair, don't bomb if already exists
    pre-up ip link add br-vlan-veth type veth peer name eth12 || true
    # Set both ends UP
    pre-up ip link set br-vlan-veth up
    pre-up ip link set eth12 up
    # Delete veth pair on DOWN
    post-down ip link del br-vlan-veth || true
    bridge_ports br-vlan-veth eth1


    # Add an additional address to br-vlan
    iface br-vlan inet static
    # Flat network default gateway
    # -- This needs to exist somewhere for network reachability
    # -- from the router namespace for floating IP paths.
    # -- Putting this here is primarily for tempest to work.
    address 172.29.248.1
    netmask 255.255.252.0
    2 changes: 2 additions & 0 deletions primary-interface
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    root@aio1:~# PRIMARY_INTERFACE=`awk '/ -A POSTROUTING -o / { print $8 }' /etc/network/interfaces.d/osa_interfaces.cfg`
    root@aio1:~# echo $PRIMARY_INTERFACE
    2 changes: 2 additions & 0 deletions update-iptables
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    root@aio1:~# iptables -t nat -D POSTROUTING -o $PRIMARY_INTERFACE -j MASQUERADE
    root@aio1:~# iptables -D POSTROUTING -t mangle -p tcp --dport 22 -j CHECKSUM --checksum-fill
  9. @lbragstad lbragstad revised this gist Aug 2, 2018. 1 changed file with 9 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions deploy
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    # git clone https://git.openstack.org/openstack/openstack-ansible /opt/openstack-ansible
    # cd /opt/openstack-ansible
    # git checkout 17.0.7
    # scripts/bootstrap-ansible.sh
    # scripts/bootstrap-aio.sh
    # cd /opt/openstack-ansible/playbooks
    # openstack-ansible setup-hosts.yml
    # openstack-ansible setup-infrastructure.yml
    # openstack-ansible setup-openstack.yml
  10. @lbragstad lbragstad revised this gist Aug 2, 2018. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions interface-rename
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    # ip link set eno1 down
    # ip link set eno1 name eth1
    # ip link set rename3 down
    # ip link set rename3 name eth0
  11. @lbragstad lbragstad revised this gist Aug 2, 2018. 1 changed file with 12 additions and 0 deletions.
    12 changes: 12 additions & 0 deletions interfaces
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    # 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/*

    # The loopback network interface
    auto lo
    iface lo inet loopback

    # The primary network interface
    auto eth1
    iface eth1 inet manual
  12. @lbragstad lbragstad created this gist Aug 1, 2018.
    163 changes: 163 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,163 @@
    # Decide a Range of IP Address Your Router Will Manage, and a Range of IP Address Neutron Will Manage
    # Adjust To Accomodate For Any Static Assignments (Such as 192.168.1.1 for Your Router)
    # Ensure These IP Address Ranges, and Any Static Assignments Do Not Overlap
    #
    # For Example:
    #
    # Home Network Subnet: 192.168.1.0/24
    # Router Static: 192.168.1.1
    # Laptop Static: 192.168.1.2
    # OSA-AIO Static: 192.168.1.3
    # Router DHCP Range: 192.168.1.4-199
    # Neutron Allocation Pool: 192.168.1.200-249
    #
    # Re-Configure Router DHCP Range Settings (refer to manufacturers documentation)
    # If Something Is Using an IP Address from Neutron Allocation Pool, Release / Renew DHCP or Reboot Device
    # An IP Address from Your Router Updated DHCP Range Should Be Assigned

    # From OSA-AIO Host, Attach to Utility Container
    lxc-attach -n `lxc-ls -1 | grep util`

    # Source Admin Credentials
    source ~/openrc

    # Observe Neutron Resources Created by Tempest
    openstack network list
    +--------------------------------------+---------+--------------------------------------+
    | ID | Name | Subnets |
    +--------------------------------------+---------+--------------------------------------+
    | 8d0d3da7-2dcd-4ddc-9f69-c62e18d9540c | public | da2100a9-bcac-4d67-848b-f451aa1779b3 |
    | ec436c94-fc2b-4640-a52a-6e38ee8e728c | private | 3a996849-6b66-4d6e-bf38-40e056331fe6 |
    +--------------------------------------+---------+--------------------------------------+

    openstack subnet list
    +--------------------------------------+----------------+--------------------------------------+-----------------+
    | ID | Name | Network | Subnet |
    +--------------------------------------+----------------+--------------------------------------+-----------------+
    | 3a996849-6b66-4d6e-bf38-40e056331fe6 | private-subnet | ec436c94-fc2b-4640-a52a-6e38ee8e728c | 192.168.74.0/28 |
    | da2100a9-bcac-4d67-848b-f451aa1779b3 | public-subnet | 8d0d3da7-2dcd-4ddc-9f69-c62e18d9540c | 172.29.248.0/22 |
    +--------------------------------------+----------------+--------------------------------------+-----------------+

    openstack router list
    +--------------------------------------+--------+--------+-------+-------------+-------+----------------------------------+
    | ID | Name | Status | State | Distributed | HA | Project |
    +--------------------------------------+--------+--------+-------+-------------+-------+----------------------------------+
    | 9dd5445c-aa72-4c4a-b5f8-6c2659a80da5 | router | ACTIVE | UP | False | False | 108ce416d8374beeb3b5dbeb0943710a |
    +--------------------------------------+--------+--------+-------+-------------+-------+----------------------------------+

    # Delete Neutron Resouces Created by Tempest
    openstack router unset --external-gateway router
    openstack router remove subnet router private-subnet
    openstack router delete router
    openstack network delete public
    openstack network delete private

    # Exit Back to OSA-AIO Host
    exit

    # Find primary network interface (eth0, ens3, etc...)
    PRIMARY_INTERFACE=`awk '/ -A POSTROUTING -o / { print $8 }' /etc/network/interfaces.d/osa_interfaces.cfg`
    echo $PRIMARY_INTERFACE

    # Move IP Configuration (Address, Netmask, Gateway, and DNS Name Servers) of $PRIMARY_INTERFACE to br-vlan
    # Edit: /etc/network/interfaces (Interfaces File and Primary Interface Name May Differ)

    === REPLACE ===

    auto eth0
    iface eth0 inet manual
    address 192.168.1.3
    netmask 255.255.255.0
    gateway 192.168.1.1
    dns-nameservers 192.168.1.1

    === WITH ===

    auto eth0
    iface eth0 inet manual

    === END REPLACE ===

    # Edit: /etc/network/interfaces.d/osa_interfaces.cfg

    === REPLACE ===

    # Add an additional address to br-vlan
    iface br-vlan inet static
    address 172.29.248.1
    netmask 255.255.252.0

    === WITH ===

    # Add an additional address to br-vlan
    iface br-vlan inet static
    address 192.168.1.3
    netmask 255.255.255.0
    gateway 192.168.1.1
    dns-nameservers 192.168.1.1

    === END REPLACE ===

    # Add $PRIMARY_INTERFACE to bridge_ports for br-vlan...
    # Edit: /etc/network/interfaces.d/osa_interfaces.cfg

    === REPLACE ===

    bridge_ports br-vlan-veth

    === WITH ===

    bridge_ports br-vlan-veth eth0

    === END REPLACE ===

    # Prevent IPTables Rules Providing NAT and Checksum Filling From Being Created
    # Edit: /etc/network/interfaces.d/osa_interfaces.cfg

    === DELETE ===

    # To ensure ssh checksum is correct
    up /sbin/iptables -A POSTROUTING -t mangle -p tcp --dport 22 -j CHECKSUM --checksum-fill
    down /sbin/iptables -D POSTROUTING -t mangle -p tcp --dport 22 -j CHECKSUM --checksum-fill
    # To provide internet connectivity to instances
    up /sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
    down /sbin/iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE

    === END DELETE ===

    # Delete Active IPTables Rules Providing NAT and Checksum Filling
    iptables -t nat -D POSTROUTING -o $PRIMARY_INTERFACE -j MASQUERADE
    iptables -D POSTROUTING -t mangle -p tcp --dport 22 -j CHECKSUM --checksum-fill

    # Reboot OSA-AIO Host to Apply Newtork Configuration Changes
    reboot

    # From "Laptop" Ensure OSA-AIO Host is Reachable
    ping -c 3 192.168.1.3
    ssh [email protected]

    # From OSA-AIO Host, Attach to Utility Container
    lxc-attach -n `lxc-ls -1 | grep util`

    # Source Admin Credentials
    source ~/openrc

    # Create Neutron Resources
    openstack network create --share --provider-network-type flat --provider-physical-network flat home
    subnet create --subnet-range 192.168.1.0/24 --allocation-pool start=192.168.1.200,end=192.168.1.249 --dns-nameserver 192.168.1.1 --gateway 192.168.1.1 --no-dhcp --network home home-subnet

    # Create Instance with Config Drive (Adjust Security Groups as Necessary to allow SSH and Ping)
    openstack server create --image ubuntu --flavor m1.small --network home --config-drive True --key-name keypair instance
    openstack server list
    +--------------------------------------+----------+--------+--------------------+--------+----------+
    | ID | Name | Status | Networks | Image | Flavor |
    +--------------------------------------+----------+--------+--------------------+--------+----------+
    | b3d4f2fc-609d-49f3-9a13-2bd226c00a95 | instance | ACTIVE | home=192.168.1.205 | ubuntu | m1.small |
    +--------------------------------------+----------+--------+--------------------+--------+----------+

    # Exit Back to OSA-AIO Host
    exit

    # From "Laptop"
    ping -c 3 192.168.1.205
    ssh -i keypair.pem [email protected]