Code Monkey home page Code Monkey logo

foreman-ansible's Introduction

Foreman Ansible Playbook

Travis License

Ansible playbook to deploy a complete up and running Foreman instance within minutes.

Features

The goal of this playbook is to offer a fully automated way to deploy a complete and ready-to-use Foreman instance within minutes.

It contains multiple different roles with numerous customizable variables, which provide the following features:

  • setup database (SQLite or MySQL)
  • setup webserver (plain nginx as a proxy or nginx-passenger)
  • setup isc-dhcp-server
  • setup TFTP server
  • setup foreman-proxy
  • setup Foreman including configuration (templates, hosts, domains, etc.)

None of the roles will install Puppet or use the official foreman-installer, instead the plain Foreman packages are used!

In addition this playbook makes use of foreman-yml to automatically configure Foreman through the API based on a YAML file, which includes adding all templates, OS, media, hosts, etc. and linking them accordingly.

Please note that at the current time the following distributions are supported:

  • Debian 7 & 8
  • Ubuntu 14.04 & 16.04
  • CentOS 6 & 7
  • Red Hat Enterprise Linux 6 & 7

Requirements

The target machine should fulfill the following requirements before the playbook is applied:

  • FQDN configured
  • SELinux disabled
  • Required ports 67, 69, 80, 443, etc. open
  • Internet and repository access (e.g. Red Hat Optional repository)

Ansible 2.0+ is required to use this playbook!

Installation

Below the required steps to execute the default playbook:

  1. Clone this repository

  2. Initialize the submodules containing the foreman-yml repository:

    $ git submodule update --init
    
  3. Install and configure Ansible to manage the target server

  4. Create an inventory file containing either the hostname or IP address of target machine:

    $ echo "$TARGET_IP" > /tmp/inventory
    
  5. Use the playbook foreman.yml to deploy a default setup with MySQL, nginx-passenger, TFTP, DHCP and foreman-proxy:

    $ ansible-playbook foreman.yml -i /tmp/inventory -u root
    
  6. After a successful deployment you should be able to access Foreman through http://$TARGET_IP/.

The password of the admin user is by default set to foreman. In addition safemode_render is changed to false.

Examples

The templates directory contains example foreman-yml YAML templates to give you a head start to bootstrap Foreman.

In addition the variables overwritten in vars/example.yml are the minimum amount of variables that need to be defined, e.g. the MySQL role does not create any users or databases by default.

Roles

Below a short overview of all included roles:

Name Description
common update apt cache
foreman add repos and install Foreman
foreman_proxy add repos, install and configure foreman-proxy
foreman_yml configure the Foreman instance with foreman-yml
isc_dhcp_server install and configure isc-dhcp-server
mysql install MySQL, create users and databases
nginx add upstream repos if requested and setup nginx
passenger_nginx add repos and setup passenger-nginx
sqlite install sqlite and create db directory
tftp install and setup TFTP including PXE boot files

Upcoming features

See the issues page for a list of upcoming and planned features.

Contributions

Contributions are more than welcome! Please feel free to open new issues or pull requests.

License

GNU GENERAL PUBLIC LICENSE Version 3

See the LICENSE file.

foreman-ansible's People

Contributors

bdurrow avatar joeisc avatar karras avatar tongpu 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

Watchers

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

foreman-ansible's Issues

Support installation of passenger from EPEL

Users should have the freedom to choose between different passenger deployments. Supporting the installation from EPEL shouldn't need major changes. Later on we can also try adding a role for apache-passenger.

Error:TASK [foreman : rake create foreman database]

fatal: [192.168.0.19]: FAILED! => {"changed": true, "cmd": ["/usr/sbin/foreman-rake", "db:migrate"], "delta": "0:00:0
3.901860", "end": "2017-03-16 21:10:19.692102", "failed": true, "rc": 1, "start": "2017-03-16 21:10:15.790242", "stde
rr": "rake aborted!\nActiveRecord::RecordInvalid: Validation failed: Value is invalid\n/opt/rh/sclo-ror42/root/usr/sh
are/gems/gems/activerecord-4.2.5.1/lib/active_record/validations.rb:79:in `raise_record_invalid'\n/opt/rh/sclo-ror42/
root/usr/share/gems/gems/activerecord-4.2.5.1/lib/active_record/validations.rb:43:in `save!'\n/opt/rh/sclo-ror42/root
/usr/share/gems/gems/activerecord-4.2.5.1/lib/active_record/attribute_methods/dirty.rb:29:in `save!'\n/opt/rh/sclo-ro
r42/root/usr/share/gems/gems/activerecord-4.2.5.1/lib/active_record/transactions.rb:291:in `block in save!'\n/opt/rh/
sclo-ror42/root/usr/share/gems/gems/activerecord-4.2.5.1/lib/active_record/transactions.rb:351:in `block in with_tran
saction_returning_status'\n/opt/rh/sclo-ror42/root/usr/share/gems/gems/activerecord-4.2.5.1/lib/active_record/connect
ion_adapters/abstract/database_statements.rb:211:in `transaction'\n/opt/rh/sclo-ror42/root/usr/share/gems/gems/active
record-4.2.5.1/lib/active_record/transactions.rb:220:in `transaction'\n/opt/rh/sclo-ror42/root/usr/share/gems/gems/ac
tiverecord-4.2.5.1/lib/active_record/transactions.rb:348:in `with_transaction_returning_status'\n/opt/rh/sclo-ror42/r
oot/usr/share/gems/gems/activerecord-4.2.5.1/lib/active_record/transactions.rb:291:in `save!'\n/opt/rh/sclo-ror42/roo
t/usr/share/gems/gems/activerecord-4.2.5.1/lib/active_record/persistence.rb:51:in `create!'\n/usr/share/foreman/app/m
odels/setting.rb:201:in `create!'\n/usr/share/foreman/app/models/setting/email.rb:29:in `block (2 levels) in load_def
aults'\n/usr/share/foreman/app/models/setting/email.rb:29:in `each'\n/usr/share/foreman/app/models/setting/email.rb:2
9:in `block in load_defaults'\n/opt/rh/sclo-ror42/root/usr/share/gems/gems/activerecord-4.2.5.1/lib/active_record/con
nection_adapters/abstract/database_statements.rb:213:in `block in transaction'\n/opt/rh/sclo-ror42/root/usr/share/gem
s/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/transaction.rb:184:in `within_new_transact
ion'\n/opt/rh/sclo-ror42/root/usr/share/gems/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract
/database_statements.rb:213:in `transaction'\n/opt/rh/sclo-ror42/root/usr/share/gems/gems/activerecord-4.2.5.1/lib/ac
tive_record/transactions.rb:220:in `transaction'\n/usr/share/foreman/app/models/setting/email.rb:13:in `load_defaults
'\n/usr/share/foreman/config/initializers/foreman.rb:25:in `each'\n/usr/share/foreman/config/initializers/foreman.rb:
25:in `<top (required)>'\n/opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/depend
encies.rb:268:in `load'\n/opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/depende
ncies.rb:268:in `block in load'\n/opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support
/dependencies.rb:240:in `load_dependency'\n/opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/acti
ve_support/dependencies.rb:268:in `load'\n/opt/rh/sclo-ror42/root/usr/share/gems/gems/railties-4.2.5.1/lib/rails/engi
ne.rb:652:in `block in load_config_initializer'\n/opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/li
b/active_support/notifications.rb:166:in `instrument'\n/opt/rh/sclo-ror42/root/usr/share/gems/gems/railties-4.2.5.1/l
ib/rails/engine.rb:651:in `load_config_initializer'\n/opt/rh/sclo-ror42/root/usr/share/gems/gems/railties-4.2.5.1/lib
/rails/engine.rb:616:in `block (2 levels) in <class:Engine>'\n/opt/rh/sclo-ror42/root/usr/share/gems/gems/railties-4.
2.5.1/lib/rails/engine.rb:615:in `each'\n/opt/rh/sclo-ror42/root/usr/share/gems/gems/railties-4.2.5.1/lib/rails/engin
e.rb:615:in `block in <class:Engine>'\n/opt/rh/sclo-ror42/root/usr/share/gems/gems/railties-4.2.5.1/lib/rails/initial
izable.rb:30:in `instance_exec'\n/opt/rh/sclo-ror42/root/usr/share/gems/gems/railties-4.2.5.1/lib/rails/initializable
.rb:30:in `run'\n/opt/rh/sclo-ror42/root/usr/share/gems/gems/railties-4.2.5.1/lib/rails/initializable.rb:55:in `block
 in run_initializers'\n/opt/rh/sclo-ror42/root/usr/share/gems/gems/railties-4.2.5.1/lib/rails/initializable.rb:44:in 
`each'\n/opt/rh/sclo-ror42/root/usr/share/gems/gems/railties-4.2.5.1/lib/rails/initializable.rb:44:in `tsort_each_chi
ld'\n/opt/rh/sclo-ror42/root/usr/share/gems/gems/railties-4.2.5.1/lib/rails/initializable.rb:54:in `run_initializers'
\n/opt/rh/sclo-ror42/root/usr/share/gems/gems/railties-4.2.5.1/lib/rails/application.rb:352:in `initialize!'\n/opt/rh
/sclo-ror42/root/usr/share/gems/gems/railties-4.2.5.1/lib/rails/railtie.rb:194:in `public_send'\n/opt/rh/sclo-ror42/r
oot/usr/share/gems/gems/railties-4.2.5.1/lib/rails/railtie.rb:194:in `method_missing'\n/usr/share/foreman/config/envi
ronment.rb:5:in `<top (required)>'\n/opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_supp
ort/dependencies.rb:274:in `block in require'\n/opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/
active_support/dependencies.rb:240:in `load_dependency'\n/opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.
2.5.1/lib/active_support/dependencies.rb:274:in `require'\n/opt/rh/sclo-ror42/root/usr/share/gems/gems/railties-4.2.5
.1/lib/rails/application.rb:328:in `require_environment!'\n/opt/rh/sclo-ror42/root/usr/share/gems/gems/railties-4.2.5
.1/lib/rails/application.rb:457:in `block in run_tasks_blocks'\nTasks: TOP => db:migrate => environment\n(See full tr
ace by running task with --trace)", "stdout": "Apipie cache enabled but not present yet. Run apipie:cache rake task t
o speed up API calls.", "stdout_lines": ["Apipie cache enabled but not present yet. Run apipie:cache rake task to spe
ed up API calls."], "warnings": []}

Add metadata to all roles

It's common practice to add (galaxy) metadata to all Ansible roles. This way they can be better integrated into other projects and the dependencies and requirements are clearer.

Check SELinux compatiblity

The playbook has so far not been tested against machines which have SELinux enabled. Maybe this will need some tweaking of the roles, e.g. install additional packages.

Define a way to describe the different roles

As the roles will grow more complex we need to define a clear way how they should be documented. Otherwise it will be too hard to customize a deployment.

At least all variables need a short comment as it's already defined in our internal guidelines. Maybe we can find a nice way to generate RST tables for all roles and variables.

Add nginx HTTPS support

Allow the configuration of the most important HTTPS settings within the nginx and passenger-nginx role.

Add deployment and development instructions

We need an easy way to deploy and test the playbook. The required steps have to be described clearly in the README. I think a docker file and vagrant config should cover most requirements.

Plain Foreman service not starting on Ubuntu 16.04 / Debian 8

Although having START=yes configured in /etc/default/foreman, the Foreman service does not seem to start on Ubuntu 16.04 and Debian 8. Maybe this issue is systemd related, or rather the init file is not properly converted by the systemd-sysv-generator.

Move roles to ansible-galaxy

Recently we split our infrastructure roles and pushed them to Galaxy: https://galaxy.ansible.com/adfinis-sygroup/

It would make sense to separate the roles of this repo as well and refactor them at the same time. Basically we could reuse existing roles (e.g. mysql) which improves maintenance and adaptability.

This repo would then serve as a central place to get started with Foreman and provide a set of nice example playbooks for different setups. Installation would be done via ansible-galaxy requirements.yml file.

What's your take @hairmare @keachi @fujexo ?

Migration status:

Add DNS role

Currently there's no role for the DNS (bind9) setup and its foreman-proxy integration. Definitely needed!

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.