Skip to content

Commit

Permalink
Merge branch 'master' into fortios-adjust-for-fortiadc
Browse files Browse the repository at this point in the history
  • Loading branch information
robertcheramy authored Feb 28, 2025
2 parents d26a00e + 03032fc commit 1b61239
Show file tree
Hide file tree
Showing 25 changed files with 320 additions and 642 deletions.
2 changes: 1 addition & 1 deletion .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2025-02-17 10:13:53 UTC using RuboCop version 1.72.1.
# on 2025-02-26 20:32:58 UTC using RuboCop version 1.73.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand Down
25 changes: 20 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,38 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
### Added

### Changed
- docker image: updated github CI to explicitly build tag versions (@robertcheramy)
- fortios: support for FortiADC (@electrocret)

### Fixed
- powerconnect: Mask the changing temperature issue for non-stacked switches. Fixes #2088 (@clifcox)


## [0.32.2 – 2025-02-27]
This patch release mainly fixes the docker building process, wich resulted in
0.32.1 not beeing built.

### Changed
- docker image: updated github CI to explicitly build tag versions (@robertcheramy)
- docker image: update rake build_container to match the tags of GitHub CI (@robertcheramy)

### Fixed
- powerconnect: restore last line of command output, and remove spurious CR characters. Fixes #2692 (@clifcox)
- powerconnect: Remove undesirable inserted blank lines during pagination. Fixes #3413 (@clifcox)
- docker image: remove ubuntu user introduced in noble (@robertcheramy)
- docker image: correct rights under /home/oxidized (@robertcheramy)
- docker image: remove ubuntu user introduced in noble. Fixes #3336 (@robertcheramy)
- docker image: correct rights under /home/oxidized. Fixes #3336 (@robertcheramy)
- docker image: revert the use of GEM_HOME. Fixes #3331 (@robertcheramy)
- docker image: improve the documentation. Fixes #3336 (@robertcheramy)
- docker image: remove examples/podman-compose as this is better documented in docs/Docker.md (@robertcheramy)


## [0.32.1 – 2025-02-20]
This minor release fixes a javascript issue in oxidized-web, which is included
This patch release fixes a javascript issue in oxidized-web, which is included
in the Docker container of oxidized.

### Fixed
- powerconnect: Hide enable, and line secrets. Further Fixes #1212 (#clifcox)


## [0.32.0 – 2025-02-17]
This release fixes a security issue in oxidized-web, which is included in the
Docker container of oxidized. If you are not using the Docker container but
Expand All @@ -46,7 +62,6 @@ use oxidized-web, be sure to update your oxidized-web gem to 0.15.0.
- extra/gitdiff-msteams.sh: honor the 28KB size limit and add an optional link to GitHub (@mopi3456)

### Fixed
- powerconnect: restore last line of command output, and remove spurious CR characters. Fixes #2692 (@clifcox)
- tplink: send 'enable' before the enable password. Fixes #3271 (@robertcheramy)
- asyncos: fix prompt for hostnames containing "-" . Fixes #3327 (@robertcheramy)
- sonicos: fix prompt for hostnames containing "-" . Fixes #3333 (@robertcheramy)
Expand Down
78 changes: 22 additions & 56 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,44 +1,3 @@
###################
# Stage 1: Prebuild to save space in the final image.

FROM docker.io/phusion/baseimage:noble-1.0.0 AS prebuilder

ENV DEBIAN_FRONTEND=noninteractive

# install necessary packages for building gems
RUN apt-get -yq update && apt-get install -yq --no-install-recommends \
build-essential \
git \
ruby-dev \
&& rm -rf /var/lib/apt/lists/*

# create bundle directory
RUN mkdir -p /usr/local/bundle
ENV GEM_HOME=/usr/local/bundle

###################
# Install the x25519 gem
RUN gem install x25519 --no-document


###################
# build oxidized
COPY . /tmp/oxidized/
WORKDIR /tmp/oxidized

# docker automated build gets shallow copy, but non-shallow copy cannot be unshallowed
RUN git fetch --unshallow || true

# Remove any older gems of oxidized if they exist
RUN rm pkg/* || true

# Build oxidized
RUN rake build


###################
# Stage2: build an oxidized container from phusion/baseimage-docker and install
# gems from stage1
FROM docker.io/phusion/baseimage:noble-1.0.0

ENV DEBIAN_FRONTEND=noninteractive
Expand Down Expand Up @@ -70,9 +29,9 @@ COPY extra/auto-reload-config.runit /etc/service/auto-reload-config/run
COPY extra/update-ca-certificates.runit /etc/service/update-ca-certificates/run

# set up dependencies for the build process
RUN apt-get -yq update \
&& apt-get -yq upgrade \
&& apt-get -yq --no-install-recommends install ruby \
RUN apt-get -qy update \
&& apt-get -qy upgrade \
&& apt-get -qy --no-install-recommends install ruby \
# Build process of oxidized from git (beloww)
git \
# Allow git send-email from docker image
Expand All @@ -97,13 +56,6 @@ RUN apt-get -yq update \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# copy the compiled gem from the builder stage
COPY --from=prebuilder /usr/local/bundle /usr/local/bundle

# Set environment variables for bundler
ENV GEM_HOME="/usr/local/bundle"
ENV PATH="$GEM_HOME/bin:$PATH"

# gems not available in ubuntu noble
RUN gem install --no-document \
# dependencies for hooks
Expand All @@ -113,11 +65,25 @@ RUN gem install --no-document \
# Net scp is needed in Version >= 4.1.0, which is not available in ubuntu
net-scp

# install oxidized from prebuilder
# The Dockerfile ist version-independent, so use oxidized-*.gem to cach the gem
RUN mkdir -p /tmp/oxidized
COPY --from=prebuilder /tmp/oxidized/pkg/oxidized-*.gem /tmp/oxidized/
RUN gem install /tmp/oxidized/oxidized-*.gem
# Prepare the build of oxidized, copy our workig directory in the container
COPY . /tmp/oxidized/
WORKDIR /tmp/oxidized

# Install gems which needs a build environment
RUN apt-get -qy update && \
apt-get -qy install --no-install-recommends \
build-essential git ruby-dev && \
##### X25519 (a.k.a. Curve25519) Elliptic Curve Diffie-Hellman
gem install x25519 && \
##### build & install oxidized from the working repository
# docker automated build gets shallow copy, but non-shallow copy cannot be unshallowed
git fetch --unshallow || true && \
rake install && \
# remove the packages we do not need.
apt-get -qy remove build-essential git ruby-dev && \
apt-get -qy autoremove && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# install oxidized-web
RUN gem install oxidized-web --no-document
Expand Down
101 changes: 3 additions & 98 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# Oxidized

[![Build Status](https://github.com/ytti/oxidized/actions/workflows/ruby.yml/badge.svg)](https://github.com/ytti/oxidized/actions/workflows/ruby.yml)
[![codecov.io](https://codecov.io/gh/ytti/oxidized/coverage.svg?branch=master)](https://codecov.io/gh/ytti/oxidized?branch=master)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/5a90cb22db6a4d5ea23ad0dfb53fe03a)](https://www.codacy.com/app/ytti/oxidized?utm_source=github.com&utm_medium=referral&utm_content=ytti/oxidized&utm_campaign=Badge_Grade)
[![Code Climate](https://codeclimate.com/github/ytti/oxidized/badges/gpa.svg)](https://codeclimate.com/github/ytti/oxidized)
[![Gem Version](https://badge.fury.io/rb/oxidized.svg)](http://badge.fury.io/rb/oxidized)
[![Join the chat at https://gitter.im/oxidized/Lobby](https://badges.gitter.im/oxidized/Lobby.svg)](https://gitter.im/oxidized/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

Expand Down Expand Up @@ -37,8 +34,7 @@ Check out the [Oxidized TREX 2014 presentation](http://youtu.be/kBQ_CTUuqeU?t=3h
* [CentOS, Oracle Linux, Red Hat Linux](#centos-oracle-linux-red-hat-linux)
* [FreeBSD](#freebsd)
* [Build from Git](#build-from-git)
* [Docker](#running-with-docker)
* [Podman-Compose](#running-with-podman-compose)
* [Docker & Podman](docs/Docker.md)
* [Installing Ruby 2.3 using RVM](#installing-ruby-23-using-rvm)
3. [Initial Configuration](#configuration)
4. [Configuration](docs/Configuration.md)
Expand Down Expand Up @@ -155,99 +151,8 @@ gem install bundler
rake install
```

### Running with Docker

Currently, Docker Hub automatically builds the master branch for linux/amd64
and linux/arm64 platforms as
[oxidized/oxidized](https://hub.docker.com/r/oxidized/oxidized/). Each official
release also gets its own tag.
You can make use of this container or build your own.

To build your own, clone git repo:

```shell
git clone https://github.com/ytti/oxidized
```

Then, build the container locally (requires docker 17.05.0-ce or higher):

```shell
docker build -q -t oxidized/oxidized:latest oxidized/
```

Once you've built the container (or chosen to make use of the automatically built container in Docker Hub, which will be downloaded for you by docker on the first `run` command had you not built it), proceed as follows:

Create a configuration directory in the host system:

```shell
mkdir /etc/oxidized
```

Run the container for the first time to initialize the config:

_Note: this step in only required for creating the Oxidized configuration file and can be skipped if you already have one._

```shell
docker run --rm -v /etc/oxidized:/home/oxidized/.config/oxidized -p 8888:8888/tcp --user oxidized -t oxidized/oxidized:latest oxidized
```

If the RESTful API and Web Interface are enabled, on the docker host running the container
edit `/etc/oxidized/config` and modify `rest: 127.0.0.1:8888` to `rest: 0.0.0.0:8888`. This will bind port 8888 to all interfaces, and expose the port so that it could be accessed externally. [(Issue #445)](https://github.com/ytti/oxidized/issues/445)

Alternatively, you can use docker-compose to launch the oxidized container:

```yaml
# docker-compose.yml
# docker-compose file example for oxidized that will start along with docker daemon
---
version: "3"
services:
oxidized:
restart: always
image: oxidized/oxidized:latest
ports:
- 8888:8888/tcp
environment:
CONFIG_RELOAD_INTERVAL: 600
volumes:
- config:/home/oxidized/.config/oxidized/
volumes:
config:
```
Create the `/etc/oxidized/router.db` (see [CSV Source](docs/Sources.md#source-csv) for further info):

```shell
vim /etc/oxidized/router.db
```

Run container again to start oxidized with your configuration:

```shell
docker run -v /etc/oxidized:/home/oxidized/.config/oxidized -p 8888:8888/tcp -t oxidized/oxidized:latest
oxidized[1]: Oxidized starting, running as pid 1
oxidized[1]: Loaded 1 nodes
Puma 2.13.4 starting...
* Min threads: 0, max threads: 16
* Environment: development
* Listening on tcp://0.0.0.0:8888
```

If you want to have the config automatically reloaded (e.g. when using a http source that changes):

```shell
docker run -v /etc/oxidized:/home/oxidized/.config/oxidized -p 8888:8888/tcp -e CONFIG_RELOAD_INTERVAL=3600 -t oxidized/oxidized:latest
```

If you need to use an internal CA (e.g. to connect to an private github instance):

```shell
docker run -v /etc/oxidized:/home/oxidized/.config/oxidized -v /path/to/MY-CA.crt:/usr/local/share/ca-certificates/MY-CA.crt -p 8888:8888/tcp -e UPDATE_CA_CERTIFICATES=true -t oxidized/oxidized:latest
```

### Running with podman-compose
Under [examples/podman-compose](examples/podman-compose), you will find a complete
example of how to integrate the container into a docker-compose.yml file.
### Running with Docker or Podman
See [docs/Docker.md](docs/Docker.md)

### Installing Ruby 2.3 using RVM

Expand Down
10 changes: 7 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,19 @@ end

desc 'Build the container image with docker or podman'
task :build_container do
branch_name = %x(git rev-parse --abbrev-ref HEAD).chop
sha_hash = %x(git rev-parse --short HEAD).chop
image_tag = "#{branch_name}-#{sha_hash}"

# Prefer podman if available as it runs rootless
if command_available?('podman')
sh 'podman build -t oxidized:`git describe --tags` -t oxidized:latest .'
sh "podman build -t oxidized:#{image_tag} -t oxidized:latest ."
elsif command_available?('docker')
if docker_needs_root?
puts 'docker needs root to build the image. Using sudo...'
sh 'sudo docker build -t oxidized:`git describe --tags` -t oxidized:latest .'
sh "sudo docker build -t oxidized:#{image_tag} -t oxidized:latest ."
else
sh 'docker build -t oxidized:`git describe --tags` -t oxidized:latest .'
sh "docker build -t oxidized:#{image_tag} -t oxidized:latest ."
end
else
puts 'You need Podman or Docker to build the container image.'
Expand Down
Loading

0 comments on commit 1b61239

Please sign in to comment.