Giter VIP home page Giter VIP logo

build-atomic-host's Introduction

Build Your Own Atomic Host

Automation of Building your own Atomic-Host. To know about Atomic-Host, please visit http://www.projectatomic.io.

Steps

Clone Source

$ git clone https://github.com/trishnaguha/build-atomic-host.git
$ cd build-atomic-host

Install Ansible

Please Make sure Ansible is intalled in your system.

$ sudo dnf install ansible   # Install python2-dnf if you are using Fedora Linux Distribution

Download Atomic QCOW2 Image

Download Fedora Atomic QCOW2 Image: https://getfedora.org/en/atomic. You can also download CentOS Atomic QCOW2 Image.

SetUp Environment

Install Requirements - Start HTTP Server. After running the following playbook you may use ip addr to check the IP Address of your HTTP server.

$ ansible-playbook setup.yml --ask-sudo-pass

Variables

Replace the Variables in vars/atomic.yml with your httpserver IP Address, OSTree name, Basehost.

If you wish to use CentOS Atomic modify the variables accordingly.

---
# Variables for Atomic host
atomicname: my-atomic
basehost: fedora-atomic/25/x86_64/docker-host
httpserver: 192.168.122.1

Add the additional Packages you would like to have in the OSTree in vars/buildrepo.yml.

If you wish to use CentOS Atomic modify the variables accordingly.

---
# Variables for Atomic repository/OSTree packages
repo: https://pagure.io/fedora-atomic.git
branch: f25
repodir: fedora-atomic
abs_path: /workspace                                  # The absolute path to the git repo.
custommanifest: customized-atomic-docker-host.json    # The manifest that goes into the custom host(ostree) content that we are going to build.
sourcemanifest: fedora-atomic-docker-host.json        # The manifest that goes into the actual Base Fedora host(ostree) content.
packages: '"vim-enhanced", "git"'                     # Packages you want to have in your Atomic host.

You can add packages like above in double-qoutes separated by comma.

Replace Variables for Creating VM from QCOW2 Image. If you wish to use CentOS Atomic modify the variables accordingly.

# Variables for Creating VM

domain: atomic-node
image: Fedora-Atomic-25-20170228.0.x86_64
cpu: 1
mem: 1536
os:
  variant: fedora23
path: /tmp

Main Playbook

Run the main Playbook which will create VM from QCOW2 image, compose OSTree and perform SSH-Setup and Rebase on OSTree:

$ ansible-playbook main.yml --ask-sudo-pass

user-name: atomic-user, password: atomic for the instance.

Reboot the Host

Now SSH to the Atomic Host and Perform a Reboot which will reboot in to your OSTree:

$ sudo systemctl reboot

Verify: SSH to the Atomic Host:

$ ssh [email protected]
[atomic-user@atomic-node ~]$ sudo rpm-ostree status
State: idle
Deployments:
โ— my-atomic:fedora-atomic/25/x86_64/docker-host
       Version: 25.1 (2017-02-07 05:34:46)
        Commit: 15b70198b8ec7fd54271f9672578544ff03d1f61df8d7f0fa262ff7519438eb6
        OSName: fedora-atomic

  fedora-atomic:fedora-atomic/25/x86_64/docker-host
       Version: 25.51 (2017-01-30 20:09:59)
        Commit: f294635a1dc62d9ae52151a5fa897085cac8eaa601c52e9a4bc376e9ecee11dd
        OSName: fedora-atomic

Shout-Out for the following folks:

build-atomic-host's People

Contributors

gbraad avatar trishnaguha avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

gbraad

build-atomic-host's Issues

Customize Packages

We need to enable customizing (add/delete) packages in fedora-atomic-docker-host.json. And make sure that the user should be able to use own customized OSTree.

Remove reboot from Playbook rebase.yml

We may want to remove reboot from Playbook as we do not have any task to perform after that.
Though having reboot in playbook makes our work fully automated but it ends up showing an ssh-connection error which doesn't look good to the user.

TASK [Perform a reboot] ********************************************************
fatal: [192.168.121.34]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh.", "unreachable": true}
 [WARNING]: Could not create retry file 'rebase.retry'.         [Errno 2] No such file or directory: ''


PLAY RECAP *********************************************************************
192.168.121.34             : ok=3    changed=2    unreachable=1    failed=0   

We can ask user to do the reboot manually instead.

Basic instruction

Dockerfile

FROM fedora:25
MAINTAINER Gerard Braad <[email protected]>

# Run update and install packages
RUN dnf update -y && \
    dnf install -y ansible && \
    dnf clean all

# Create working dir
RUN mkdir -p /workspace
ADD ./compose.yml /workspace

# Compose (result will be in /srv/repo)
RUN cd /workspace && ansible-playbook compose.yml

# Expose web server port, set working dir
EXPOSE 8000
WORKDIR /workspace
VOLUME /workspace

# Start web server
CMD ostree trivial-httpd -p 8000 /srv/repo

compose.yml

#!/usr/bin/env ansible-playbook
---
- hosts: localhost

  tasks:
  - name: Install list of required packages
    package: name={{ item }} state=installed
    become: yes
    become_method: sudo
    with_items:
    - git
    - rpm-ostree

  - name: Clean package cache
    command: >-
      dnf clean all
      
  - name: Create directory structure
    file: path="{{ item }}" state=directory mode=750
    with_items:
    - "/srv/repo"
    - "/workspace"

  - name: Initialize repository
    command: >-
      ostree --repo=/srv/repo init --mode=archive-z2

  - name: Clone Fedora-Atomic buildscripts
    git: >-
      repo=https://pagure.io/fedora-atomic.git
      version=f25
      depth=1
      dest=/workspace/fedora-atomic

  - name: Compose Fedora-Atomic tree
    command: >-
      chdir=/workspace/fedora-atomic/
      rpm-ostree compose tree --repo=/srv/repo ./fedora-atomic-docker-host.json

#  - name: Start webserver
#    command: >-
#      ostree trivial-httpd -p 8000 /srv/repo

The Dockerfile might not run as it creates new namespaces during the compose step, however it describes what is needed. Maybe a Vagrantfile would have been better. Anyways, this will result in a Atomic host tree that can be served over http as static assets by nginx or by ostree trivial-httpd. Retested this process at: https://gitlab.com/gbraad/byo-atomic-fedora, Source: https://github.com/gbraad/byo-atomic-fedora

The tree can be used on the Atomic host as:

sudo ostree remote add byo-atomic-fedora http://[hostname]:8000 --no-gpg-verify
sudo rpm-ostree rebase byo-atomic-fedora:fedora-atomic/f25/x86_64/docker-host
systemctl reboot

Bare Metal Provisioning Support

Hi @trishnaguha ,
first of all I must say this is great work here and in the blogs, really helpful! Thank you :)

I have a use case where I'd like to roll my own ostree and use that to provision bare metal machines.

A playbook for that wouldn't really be overly complex, I hope:
One could create and serve a Kickstarter file to tell Anaconda to directly install the OS from OStree. No need to rebase later. How to do that in an (almost) unattended way is already documented here. You then only need to have grub on the machine and alter it manually.
This could be fully automated with addition of a PXEboot server.

Is this something you'd be willing to support here in this repo? I will likely do some work on this soon and would happily upstream to this repo.

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.