Giter Site home page Giter Site logo

wannacfuture / jenkins-ansible-role Goto Github PK

View Code? Open in Web Editor NEW

This project forked from infraform/jenkins-ansible-role

6.0 0.0 0.0 113 KB

Provision Jenkins Server and Configure with Terraform and Ansible Role.

License: Apache License 2.0

Groovy 11.50% HCL 88.50%

jenkins-ansible-role's Introduction

Jenkins Server Ansible Role

Jenkins Server Provisioning with Ansible Role

Github top language Github language count Repository size License

About   |   Contents   |   Technologies   |   Requirements   |   Starting   |   License   |   Author


🎯 About

Jenkins Server Provisioning with Ansible Role. Checkout the main.yml file for steps to use this role.

✨ Contents

🚀 Technologies

The following tools were used in this project:

✅ Requirements

Before starting 🏁, you need to have Git and Terraform installed on your machine.

🏁 Starting

# Clone the project
git clone https://github.com/devenes/jenkins-server-ansible-role.git

# Access the project folder
cd jenkins-server-ansible-role

# Edit your backend, variables and initialize terraform
terraform init

# Run the project with terraform
terraform apply -auto-approve

🚀 Usage

  • Check if Ansible is installed and connected to your hosts
ansible all --list-hosts
ansible all -m ping -o
  • Initialize Ansible role with using Ansible Galaxy
ansible-galaxy init roles/jenkins_build
  • Encrypt the Jenkins server login password with using Ansible Vault
ansible-vault encrypt secret.yml
# You can encrypt the password with:
# ansible-vault decrypt secret.yml
  • Run the project playbook with Ansible
ansible-playbook play.yml --ask-vault-pass
  • Write the Jenkins job to the xml file with using Ansible as management tool
ansible all -b -m shell -a "sudo java -jar /root/jenkins-cli.jar -s http://localhost:8080/ -auth @/root/jenkinsauth get-job "job_template" > /root/job.xml"
  • Get the Jenkins job
ansible all -b -m shell -a "cat /root/job.xml"
  • Get the Jenkins Password
ansible all -m shell -a "sudo cat /var/lib/jenkins/secrets/initialAdminPassword"

💄 Groovy Script

Write the Groovy script to create the login credentials for the Jenkins server with using Ansible as automation tool.

import jenkins.model.*
import hudson.security.*

def instance = Jenkins.getInstance()

println "--> creating local user 'admin'"

def hudsonRealm = new HudsonPrivateSecurityRealm(false)
hudsonRealm.createAccount('admin', '{{ admin_pass }}')
instance.setSecurityRealm(hudsonRealm)

def strategy = new FullControlOnceLoggedInAuthorizationStrategy()
strategy.setAllowAnonymousRead(false)
instance.setAuthorizationStrategy(strategy)
instance.save()

📝 License

This project is under license from Apache 2.0. For more details, see the LICENSE file.

👷 Author Information

Made with ❤️ by devenes

 

Back to top

jenkins-ansible-role's People

Contributors

devenes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

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.