Giter VIP home page Giter VIP logo

efs2's Introduction

Efs2

Don't you wish you could configure a server as easily as creating a Docker image? Meet Efs2, A dead simple configuration management tool that is powered by stupid shell scripts.

Efs2 is an idea to combine the stupid shell scripts philosophy of fss with the simplicity of a Dockerfile.

PkgGoDev Go Report Card Build Status Coverage Status

Getting Started

Let's take a look at how easy it is to use Efs2 to configure NGINX on Ubuntu.

Installation

Efs2 is simple to install, with the fastest method being to download one of our binary releases.

It is also possible to install Efs2 with Go (requires v1.14+).

$ go get -u github.com/madflojo/efs2

Once installed, we can start defining our steps to setup NGINX.

The Efs2file

An Efs2file powers Efs2's configuration; much like a Dockerfile, this file uses a simple set of instructions to configure our target servers.

# Install and Configure NGINX

# Run apt-get update
RUN apt-get update --fix-missing && apt-get -y upgrade

# Install nginx
RUN apt-get install nginx

# Deploy Config files
PUT example.com.conf /etc/nginx/sites-available/example.com.conf 0644

# Create a Symlink
RUN ln -s /etc/nginx/sites-available/example.com.conf /etc/nginx/sites-enabled/example.com.conf

# Restart NGINX
RUN systemctl restart nginx

The above Efs2file showcases how simple the Efs2 instructions are. Our NGINX server is configured with two simple instructions RUN and PUT.

The RUN instruction is simple; it executes whatever command you provide. The PUT instruction uploads files. That's it, that's all the instructions included with Efs2. Simple but effective.

Remote Execution

Efs2 uses SSH to execute the instructions specified within the Efs2file. Just run the Efs2 command, followed by the target hosts.

$ efs2 host1.example.com host2.example.com

Command-Line Options

Efs2 offers several additional options, such as parallel execution and various authentication methods.

  -v, --verbose   Enable verbose output
  -q, --quiet     Silence output
  -f, --file=     Specify an alternative Efs2File (default: ./Efs2file)
  -i, --key=      Specify an SSH Private key to use (default: ~/.ssh/id_rsa)
  -p, --parallel  Execute tasks across multiple hosts in parallel
  -d, --dryrun    Print tasks to be executed without actually executing any tasks
      --port=     Define an alternate SSH Port (default: 22)
  -u, --user=     Remote host username (default: current user)
      --passwd    Ask for a password to use for host authentication

Call to Action

Efs2 is a small project to fit the fine line between complex configuration management and simple shell scripts. We are always looking for users to share their stories and contribute to our examples repository.

For those interested in helping develop Efs2. The time, skills, and perspectives you contribute to this project are valued. Please reference our Issues Page for open ideas and our Contributing Guide for contribution details.

If you like Efs2, please tell others about it by sharing this project on the social media site of your choice.

efs2's People

Contributors

dependabot[bot] avatar madflojo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

efs2's Issues

Strategy for linux-dialog style interactive shells (popular with OS installers on raspberry-pi sized devices)

Describe the idea

I've a fleet os Raspberry Pi's and smaller less well known devices (Odroid). First boot or first SSH connection of these things oftent goes into an interactive session for initial setup. Completing that workflow before attaching Efs2 for proper post boot setup is a need.

Describe possible implementations

Dialog is a thing that people use. Automating it is a frequent question on Stack Overflow (etc) - https://superuser.com/questions/1041735/automating-dialog - one of the answers links to https://stackoverflow.com/questions/3804577/have-bash-script-answer-interactive-prompts. This seems limited though.

There's https://pypi.org/project/webssh/ which could be used with Selenium (I'm co-creator of v1 back in 2004) to do any timing sensitive navigation of DOM representation of the terminal, and complete that setup.

With that, you'd launch wssh in the background, open selenlium-webdriver, do the needed one-time setup, exit, kill the wssh process.

Then you'd go back in with Efs2 to o the rest (reset default passwords, packages, etc)

Question: Is this the right approach or does Efs2 have a different way?

Additional context

Some little devices have something closer to cloud-init for setup, but there's huge variance for the different OSs that can be used.

Brew install

Describe the idea

The installation of Efs2 should be as easy as possible. For Mac OS, that means getting into the Brew list of installable programs.

Describe possible implementations

Brew has custom taps that can be used to package and distribute Efs2.

https://docs.brew.sh/How-to-Create-and-Maintain-a-Tap

Additional context

Probably need another issue like this for Linux.

efs2 does not accept encrypted private keys

With passphrase on key:

efs2 -i /Users/hbokh/.ssh/id_rsa -v -u root hostname.home
Unable to setup SSH client configuration - Unable to read private key file - ssh: cannot decode encrypted private keys

With empty passphrase on key (host was down hence the other errors):

efs2 -i /Users/hbokh/.ssh/id_rsa_nopassphrase -v -u root hostname.home
linux008.internal:22: Executing task 0 - RUN CMD apt-get update
linux008.internal:22: Error connecting to host - dial tcp 192.168.1.1:22: getsockopt: operation timed out
linux008.internal:22: Error executing command - dial tcp 192.168.1.1:22: getsockopt: operation timed out

Since I only use passphrased keys, this is somewhat of a showstopper for me... Can this be fixed?

Document RUN SCRIPT

Describe the idea

After I discovered efs2 shortly I wondered how one could execute arbitrary scripts or programs remotely. Sure you, can

PUT script.sh /tmp/script.sh 0700
RUN /tmp/script.sh; rm /tmp/script.sh

But that seemed not very userfriendly to me.

Then I discovered in that there were once RUN CMD and RUN SCRIPT commands. Now there is only RUN (which is the same as RUN CMD I think). RUN SCRIPT is still there, but undocumented.

Describe possible implementations

Keep RUN SCRIPT and document it.

Suggested Improvement: For security reasons mktemp(1) should be used to create the temporary script on the target.

put file error with permission deny

image

so, if not root user, how to offer authentication info to efs2 so that it can copy the file to root permission folders?

run sudo is not an option, I think

Default config file

Describe the idea

It would be an advantage to have a configuration file where you could write the default in, so you don't have to always give the parameters.

Describe possible implementations

In the HOME directory, look in the .config folder for an efs2 with a file named config.yml.
The structure could be as follows:

verbose: false
ssh_key: ~/.ssh/id_dsa
ssh_port: 2000
ssh_user: root

Maybe it is possible to adjust config/config.go so that it first searches for the config file, and then reads the parameters of the input from the terminal.

Wee --passwd bug

Describe the bug

--passwd is part of the CLI. At face value it suggests that it is for the remote account's password, but it is actually for the passphrase of the SSH private key locally.

Expected behavior

I would think this would be better as --passphrase or --pki-passphrase

Multiline string way of specifying PUT

Describe the idea

PUT command enhanced like so for new optional way:

PUT """ blah
        blah
        blah ...""" /etc/nginx/nginx.conf 0644

Additional context

In some cases items to be PUT on the target vm are short/clear and inlining them might boost the quick learning of the Es2file.

Recipes repo - efs2-recipes

Goal

An exchange for people wanting to read and contribute to Efs2file scripts that purport to do something useful that others may want to copy.

Design

Some directory structure:

components/
  nginx/
    static-content/
      Efs2file
      readme.md
  sinatra/
    hello-world/
      Efs2file
      readme.md
applications/
  plex-server
    default-setup/
      Efs2file
      readme.md

Examples

The Nginx example of the main README could also exist in this directory structure.

Unknowns

Efs2 doesn't purport to provide a language that adapts to apk/apt/rpm differences, so that might need to be codified in the file or directory naming:

applications/
  plex-server
    default-setup-debian8-and-lower/
      Efs2file
      readme.md
    default-setup-debian9-and-above/
      Efs2file
      readme.md

Multiline Shell commands are not supported

Describe the bug

Currently, only single-line shell commands are supported.

To Reproduce

This works:

RUN this command does stuff

This doesn't:

RUN this command \
does stuff

Expected behavior

When using multi-line commands, Efs2 should detect the \ and adjust the commands appropriately.

why don't make RUN CMD and RUN SCRIPT just be RUN?

say, the following works:

RUN CMD cd elasticsearch-6.2.3 && sudo sysctl -w vm.max_map_count=262144

but this will NOT:

RUN CMD cd elasticsearch-6.2.3 && ./bin/elasticsearch -d -p pid or RUN CMD cd elasticsearch-6.2.3 && ./bin/elasticsearch -d -p pid

but it's a common sense to combine and run like this.

we can parse this line and send to server, I don't think this is difficult, but I am not a gopher so I can't make my hand dirty, hope this can be done in the near future.

:)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.