domingo, 5 de novembro de 2017
quinta-feira, 2 de novembro de 2017
Install Jenkins on Ubuntu 16.04
1. Introduction
2. Step by Step
2.1. Prerequisites
2.1.a. Check Memory available
- 1 GB of RAM minimum;
- 4 GB desired;
2.1.b. System Update
$ sudo apt-get update2.2. Install Jenkins
$ wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key | sudo apt-key add -
OK
$ cat /etc/apt/sources.list.d/jenkins.list
deb http://pkg.jenkins.io/debian-stable binary/
$ sudo apt-get update
2.3. Upgrade Jenkins version ( optional )
$ sudo apt-get update
$ sudo apt-get install jenkins
2.4. Cheking services
$ # Ubuntu/Debian (different from CentOs/Fedora) usually starts software after installation
$ # Jenkins will be started as a deamon service named 'jenkins'
$ # See /etc/init.d/jenkins for more details. Log file will be placed in /var/log/jenkins/jenkins.log.
$ # Config parameters like JENKINS_HOME and etc, will be captured on /etc/default/jenkins
$ # By default, Jenkins listen on port 8080. Edit /etc/default/jenkins to change port
$ # To start-stop-status service do: sudo service jenkins stop; sudo service jenkins start; sudo service jenkins status
2.5. Check/allow firewall rules
a) Check firewall status - Inactive? Great nothing to do
$ sudo ufw status
Status: inactive
b) Check firewall status - Active? add rule to allows Jenkins port
$ sudo ufw statusStatus: active
:
8080 ALLOW Anywhere
:
$ sudo ufw allow 8080
2.6. Setting up Jenkins
a) Access Jenkins interface on browser and you'll see "Unlock Jenkins screen"
$ sudo cat /var/lib/jenkins/secrets/initialAdminPassword
+------------------------------------------------+
| Unlock Jenkins |
| : : |
| /var/lib/jenkins/secrets/initialAdminPassword |
| Administrator password |
| [ ] | <- paste here
+------------------------------------------------+
b) Install suggested plugins
+------------------------------------------------+
| Customize Jenkins |
| +------------------+ |
| |Install Suggested | |
| | Pluggins | | <- click button
| +------------------+ |
+------------------------------------------------+
c) Create first admin user
+------------------------------------------------+
| Create first admin user |
| Username: [admin] |
| Password: [admin] |
+------------------------------------------------+
3. References
- https://wiki.jenkins.io/display/JENKINS/Installing+Jenkins+on+Ubuntu
- https://www.digitalocean.com/community/tutorials/how-to-install-jenkins-on-ubuntu-16-04
- https://vexxhost.com/resources/tutorials/how-to-install-configure-and-use-jenkins-on-ubuntu-14-04/
quinta-feira, 20 de julho de 2017
Manipulating text files on linux
1. Introdução
This post gathers information about how to manipulates text files on linux systems.2. Referências
terça-feira, 18 de julho de 2017
How to Increase the size of a Linux LVM by adding a new disk
1. Introduction
This post olny gathers information about how to increase size linux LVM.
2. References
* https://www.rootusers.com/how-to-increase-the-size-of-a-linux-lvm-by-adding-a-new-disk/
sexta-feira, 2 de junho de 2017
DOCKER Faq, HowTo, Referece, Sample Install Run PostgreSQL in a Docker
1. Introduction
This post gathers information about PostgreSQL and Docker.2. Step-by-Step
2.1. Ensure Docker, Docker Compose are working
# docker --versionDocker version 17.03.1-ce, build c6d412e
# docker-compose --version
docker-compose version 1.11.2, build dfed245
2.2. Install a PostgreSQL Docker
- Determining PostgreSQL Docker Version to install
# psql --version
psql (PostgreSQL) 9.6.3
- Pull docker image versions
# docker pull postgres:9.6.3-alpine
# docker pull postgres:9.6.3
- Run PostgreSQL Docker Image in background - database instance
# docker run --name postgres-01 -e POSTGRES_PASSWORD=mysecretpassword -d postgres:9.6.3-alpine
# docker run --name postgres-02 -e POSTGRES_PASSWORD=mysecretpassword -d postgres:9.6.3
- Check both Docker process images running
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
676278f9f054 postgres:9.6.3 "docker-entrypoint..." 7 seconds ago Up 7 seconds 5432/tcp postgres-02
0d93213e347e postgres:9.6.3-alpine "docker-entrypoint..." 12 seconds ago Up 11 seconds 5432/tcp postgres-01
- Stop Docker instance "postgres-02"
# docker stop postgres-02
# docker kill postgres-02
- Run PostgreSQL psql command line, linked to running instance "postgres-01", using interative mode. Interate with application saying the password "mysecretpassword"
# docker run --name postgres-psql-01 -it --rm --link postgres-01:postgres postgres psql -h postgres-01 -U postgres:9.6.3-alpine
Password for user postgres: mysecretpassword
psql (9.6.3)
Type "help" for help.
postgres=# select current_date;
date
------------
2017-06-03
(1 row)
postgres=# \q
- Run PostgreSQL plsql command line, linked to running instance "postgres-01", using interative mode, using password in command line
3. References
- https://hub.docker.com/_/postgres/
- https://docs.docker.com/compose/rails/
- http://blog.kontena.io/rails-5-and-docker/
- https://stackoverflow.com/questions/29600369/starting-and-populating-a-postgres-container-in-docker
- https://github.com/kiasaki/docker-alpine-postgres/issues/18
RAILS Faq, HowTo, Reference, Sample Setup a Rails App With Apache and Passenger on CentOS 6
1. Introduction
This post gathers information about how to setup RAILS APP with Apache and Passenger on CentOS 6.
2. Step-by-Steyp
- Step#1: First of all, mantain your linux so up-to-date
# yum update
- Step#2: Install Apache
# yum install httpd
- Step#3: Install apache
# yum install httpd curl-devel httpd-devel
- Step#4: Get Apache to start on boot:
# chkconfig httpd on
- Step#5: Install Phusion Passenger and dependency packages
# gem install passenger
# yum install curl-devel httpd-devel
- Step#6: Compile the environment:
# passenger-install-apache2-module
- Step#7 Edit the Apache config file in etc/httpd/conf/httpd.conf
Paste the output from (Step#6 Compile environment) anywhere at the end of the file, eg:
# vim etc/httpd/conf/httpd.conf
LoadModule passenger_module /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.41/buildout/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.41
PassengerDefaultRuby /usr/local/rvm/gems/ruby-2.1.1/wrappers/ruby
<VirtualHost *:80>
ServerName 1.2.3.4 # www.whatever.com
DocumentRoot /var/www/rails/public # the path to your rails app
<Directory /var/www/rails/public>
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>
3. References
https://www.digitalocean.com/community/tutorials/how-to-setup-a-rails-4-app-with-apache-and-passenger-on-centos-6https://stackoverflow.com/questions/5584759/start-rails-server-automatically-after-boot
terça-feira, 23 de maio de 2017
RAILS Faq HowTo Reference Sample Using scopes on Rails to Filter index page and Re-display filter inputs
1. Introduction
This post gathers information about FAQ-Frequently Asked Question, How To, technical document references and samples about these RAILS topics.- Using scopes on Rails to Filter index page and Re-display filter inputs
2. FAQ, HOWTO, REFERENCES, SAMPLES, etc
2.1. Create model scopes for each filter condition
# vim app/models/cluster_config.rb
class ClusterConfig < ApplicationRecord
include Filterable
scope :cluster_config, -> (id) { where id: id}
scope :cluster_status, -> (cluster_status_id) { where cluster_status_id: cluster_status_id}
scope :cluster_environment_type, -> (cluster_environment_type_id) { where cluster_environment_type_id: cluster_environment_type_id}
scope :cluster_content_type, -> (cluster_content_type_id) { where cluster_content_type_id: cluster_content_type_id}
end
2.2. Implement generic filter on model concerns
# vim app/models/concerns/filterable.rb
module Filterable
extend ActiveSupport::Concern
module ClassMethods
def filter(filtering_params)
results = self.where(nil)
filtering_params.each do |key, value|
results = results.public_send(key, value) if value.present?
end
results
end
end
end
2.3. Implement filter on index controller
# vim app/controllers/cluster_configs_controller.rb
class ClusterConfigsController < ApplicationController
before_action :set_cluster_config, only: [:show, :edit, :update, :destroy]
:
def index
@cluster_configs = ClusterConfig.filter(params.slice(:cluster_config, :cluster_status, :cluster_environment_type, :cluster_content_type)).paginate(page: params[:page], per_page: 20)
end
:
private
def set_cluster_config
@cluster_config = ClusterConfig.find(params[:id])
end
:
def cluster_config_params
params.require(:cluster_config).permit(:cluster_status_id, :cluster_environment_type_id, :cluster_content_type_id, :url_rest_service, :db_host, :db_port, :db_name, :dt_created, :dt_delivered, :obs)
end
end
2.4. Implement filter on index viewer
# vim app/views/cluster_configs/index.html.erb
<h3>Filter by:</h3>
<%= form_for cluster_configs_path do %>
<div>
Id: <%= text_field_tag 'cluster_config', '' %>
Status Massa: <%= select("cluster_status", "cluster_status", ClusterStatus.all.map {|a| [a.cluster_status, a.id] }, { include_blank: true }) %>
Environment Type: <%= select("cluster_environment_type", "cluster_environment_type", ClusterEnvironmentType.all.map {|a| [a.cluster_environment_type, a.id] }, { include_blank: true }) %>
Content Type: <%= select("cluster_content_type", "cluster_content_type", ClusterContentType.all.map {|a| [a.cluster_content_type, a.id] }, { include_blank: true }) %>
<br><br>
<%= submit_tag 'Filter' %>
<br><br>
</div>
<% end %>
2.5. Erro
Error when "Filter" submit button
ActionController::ParameterMissing in ClusterConfigsController#create
param is missing or the value is empty: cluster_config
Extracted source (around line #73):
72: def cluster_config_params
73: params.require(:cluster_config).permit(:cluster_status_id, :cluster_environment_type_id, :cluster_content_type_id, :url_rest_service, :db_host, :db_port, :db_name, :dt_created, :dt_delivered, :obs)
74: end
Request
Parameters:
{"utf8"=>"✓",
"authenticity_token"=>"BF22bYvS/UXHOgeLLXeindCqWeXj41w/MxPE93cNoLBnaGwMhdC+HOuvvc6TCoteFHTsyyCZsoxO2j0kA4q/yA==",
"cluster_config"=>"",
"cluster_status"=>{"cluster_status"=>""},
"cluster_environment_type"=>{"cluster_environment_type"=>""},
"cluster_content_type"=>{"cluster_content_type"=>""},
"commit"=>"Filter"}
3. References
- http://www.justinweiss.com/articles/search-and-filter-rails-models-without-bloating-your-controller/
- https://stackoverflow.com/questions/6903339/rails-filter-index-page-and-re-display-filter-inputs
- https://stackoverflow.com/questions/19199994/rails-4-filter-index-via-collection-select-values-in-a-form-on-index-action
- https://stackoverflow.com/questions/6462956/rails-select-tag-setting-include-blank-and-selecting-a-default-value
Assinar:
Postagens (Atom)