100%[=====================================================================================================================================================================================================================================>] 71 --.-K/s in 0s
Total download size: 74 M Installed size: 74 M Is this ok [y/d/N]: y Downloading packages: jenkins-2.182-1.1.noarch.rpm | 74 MB 00:05:37 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : jenkins-2.182-1.1.noarch 1/1 Verifying : jenkins-2.182-1.1.noarch 1/1
Installed: jenkins.noarch 0:2.182-1.1
Complete!
web port & firewall
jenkins의 서비스 port를 설정 하고 열어준다.
[root@localhost devops]# cd /etc/sysconfig/ [root@localhost sysconfig]# vi jenkins
## Type: integer(0:65535) ## Default: 8080 ## ServiceRestart: jenkins # # Port Jenkins is listening on. # Set to -1 to disable # JENKINS_PORT="9090"
Total download size: 9.8 M Installed size: 40 M Is this ok [y/d/N]: y Downloading packages: java-1.8.0-openjdk-devel-1.8.0.212.b04-0.el7_6.x86_64.rpm | 9.8 MB 00:00:01 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : 1:java-1.8.0-openjdk-devel-1.8.0.212.b04-0.el7_6.x86_64 1/1 Verifying : 1:java-1.8.0-openjdk-devel-1.8.0.212.b04-0.el7_6.x86_64 1/1
[root@localhost secrets]# git bash: git: 명령을 찾을 수 없습니다... [root@localhost secrets]# yum install git Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: centos.mirror.moack.net * extras: centos.mirror.moack.net * updates: centos.mirror.moack.net Resolving Dependencies --> Running transaction check ---> Package git.x86_64 0:1.8.3.1-20.el7 will be installed --> Processing Dependency: perl-Git = 1.8.3.1-20.el7 for package: git-1.8.3.1-20.el7.x86_64 --> Processing Dependency: perl(Term::ReadKey) for package: git-1.8.3.1-20.el7.x86_64 --> Processing Dependency: perl(Git) for package: git-1.8.3.1-20.el7.x86_64 --> Processing Dependency: perl(Error) for package: git-1.8.3.1-20.el7.x86_64 --> Running transaction check ---> Package perl-Error.noarch 1:0.17020-2.el7 will be installed ---> Package perl-Git.noarch 0:1.8.3.1-20.el7 will be installed ---> Package perl-TermReadKey.x86_64 0:2.30-20.el7 will be installed --> Finished Dependency Resolution
Dependencies Resolved
=============================================================================================================================================================================================================================================================================== Package Arch Version Repository Size =============================================================================================================================================================================================================================================================================== Installing: git x86_64 1.8.3.1-20.el7 updates 4.4 M Installing for dependencies: perl-Error noarch 1:0.17020-2.el7 base 32 k perl-Git noarch 1.8.3.1-20.el7 updates 55 k perl-TermReadKey x86_64 2.30-20.el7 base 31 k
새로운 아이템 > Enter an item name "아무거나"> pipeline 선택 > ok
"아무거나" 파이프라인 설정 페이지 > pipeline tab 클릭
definition : pipeline script > github + maven > 저장
처음화면으로 이동
아무거나 파이프라인 > name > 아래화살표 > build now
파이프라인 스크립트 기초
node { def mvnHome stage('Preparation') { // for display purposes // Get some code from a GitHub repository git 'https://github.com/jglick/simple-maven-project-with-tests.git' // Get the Maven tool. // ** NOTE: This 'M3' Maven tool must be configured // ** in the global configuration. mvnHome = tool 'M3' } stage('Build') { // Run the maven build withEnv(["MVN_HOME=$mvnHome"]) { if (isUnix()) { sh '"$MVN_HOME/bin/mvn" -Dmaven.test.failure.ignore clean package' } else { bat(/"%MVN_HOME%\bin\mvn" -Dmaven.test.failure.ignore clean package/) } } } stage('Results') { junit '**/target/surefire-reports/TEST-*.xml' archiveArtifacts 'target/*.jar' } }
서술적 파이프 라인
Node 블록 + 스테이지 블록 + 디렉티브 스탭 = 서술적 파이프라인
node 블록 (필수)
node (<parameter>){<constituents>}
노드 블록(젠킨스 에이전트) = 스테이지 블록 + 디렉티브 + 스탭
node {
스테이지 블록 (필수)
stage (<parameter>){<constituents>}
스테이지 블록 = 스텝 + 디렉티브
stage('Preparation') { // for display purposes
} stage('Build') { // Run the maven build
} stage('Results') {
}
디렉티브 (옵션)
def mvnHome
mvnHome = tool 'M3'
환경변수, 옵션, 파라미터, 트리거 등을 표현
github 연결하기
Credentials 설정
Jenkins 대쉬보드(최상위 화면)
Credentials > System > Global credentials > Add Credentials
Kind : Username with password
Scope : Global
Username : github id, name 또는 email
password : github password
ID : id
Description : 아무거나
Credentials 연결
Jenkins 대쉬보드(최상위 화면)
Jenkins관리 > 시스템설정
GitHub 영역으로 이동
Name : 아무거나
API URL : https://api.github.com
Manage hooks : 선택
2번째 고급 클릭
Additional actions : Convert login and password to token 선택
From credentionas > Credentilas > 상위 만든 Credentials 선택
Create token credentials 클릭
정상적으로 토큰이 생성 되었다면 "저장" 후 종료
github 사이트 > 우상단 내 아이콘 클릭 > Setting 클릭
Developer setting 클릭
Personal access tokens 선택
github 사이트에 기 등록된 token이 양쪽다 등록 되었다면 정상 처리 완료 된 것임
# Modify these options if you want to change the way the docker daemon runs OPTIONS='--selinux-enabled --log-driver=journald --signature-verification=false' if [ -z "${DOCKER_CERT_PATH}" ]; then DOCKER_CERT_PATH=/etc/docker fi
# Do not add registries in this file anymore. Use /etc/containers/registries.conf # instead. For more information reference the registries.conf(5) man page.
# Location used for temporary files, such as those created by # docker load and build operations. Default is /var/lib/docker/tmp # Can be overriden by setting the following environment variable. # DOCKER_TMPDIR=/var/tmp
# Controls the /etc/cron.daily/docker-logrotate cron job status. # To disable, uncomment the line below. # LOGROTATE=false
# docker-latest daemon can be used by starting the docker-latest unitfile. # To use docker-latest client, uncomment below lines #DOCKERBINARY=/usr/bin/docker-latest #DOCKERDBINARY=/usr/bin/dockerd-latest #DOCKER_CONTAINERD_BINARY=/usr/bin/docker-containerd-latest #DOCKER_CONTAINERD_SHIM_BINARY=/usr/bin/docker-containerd-shim-latest
저는 상위 파일 수정으로 성공 하였습니다. 주의 해야하는 것은 tcp 이후 0.0.0.0 이 아니 127.0.0.1로 쓰게 되면 local 접근만 되고 대외 접근은 불가 합니다.
서비스 재 실행 및 TEST
demon 재실행 : systemctl daemon-reload
서비스 재실행 : service docker restart
Test : curl -X GET http://localhost:4243/images/json
[root@localhost system]# systemctl daemon-reload [root@localhost system]# service docker restart Redirecting to /bin/systemctl restart docker.service [root@localhost system]# curl -X GET http://localhost:4243/images/json [{"Containers":-1,"Created":1561408399,"Id":"sha256:36b0df681a47e5948f2088a446652766132141175dece2d6d47ef6e749385c05","Labels":{"com.sonatype.license":"Apache License, Version 2.0","com.sonatype.name":"Nexus Repository Manager base image","org.label-schema.build-date":"20190305","org.label-schema.license":"GPLv2","org.label-schema.name":"CentOS Base Image","org.label-schema.schema-version":"1.0","org.label-schema.vendor":"CentOS","vendor":"Sonatype"},"ParentId":"","RepoDigests":["docker.io/sonatype/nexus3@sha256:970b09779992bf88d041d074428c54dc153f7b9c8cafe4ff364dd26d69200f7a"],"RepoTags":["docker.io/sonatype/nexus3:latest"],"SharedSize":-1,"Size":581556647,"VirtualSize":581556647},{"Containers":-1,"Created":1546306167,"Id":"sha256:fce289e99eb9bca977dae136fbe2a82b6b7d4c372474c9235adc1741675f587e","Labels":null,"ParentId":"","RepoDigests":["docker.io/hello-world@sha256:41a65640635299bab090f783209c1e3a3f11934cf7756b09cb2f1e02147c6ed8"],"RepoTags":["docker.io/hello-world:latest"],"SharedSize":-1,"Size":1840,"VirtualSize":1840}]
[devops@localhost ~]$ su 암호: [root@localhost devops]# yum -y install gcc dkms make qt libgomp patch Loaded plugins: fastestmirror, langpacks base | 3.6 kB 00:00:00 docker-ce-stable | 3.5 kB 00:00:00 epel | 5.3 kB 00:00:00 extras | 3.4 kB 00:00:00 maradb | 2.9 kB 00:00:00 updates | 3.4 kB 00:00:00 webtatic | 3.6 kB 00:00:00 (1/2): epel/x86_64/primary_db | 6.1 MB 00:00:05 (2/2): epel/x86_64/updateinfo | 782 kB 00:00:11 Loading mirror speeds from cached hostfile * base: centos.mirror.moack.net * extras: data.aonenetworks.kr * updates: mirror.kakao.com * webtatic: us-east.repo.webtatic.com Resolving Dependencies --> Running transaction check ---> Package dkms.noarch 0:2.4.0-1.20170926git959bd74.el6 will be installed --> Processing Dependency: elfutils-libelf-devel for package: dkms-2.4.0-1.20170926git959bd74.el6.noarch --> Processing Dependency: kernel-devel-uname-r for package: dkms-2.4.0-1.20170926git959bd74.el6.noarch ---> Package gcc.x86_64 0:4.8.5-11.el7 will be updated --> Processing Dependency: gcc = 4.8.5-11.el7 for package: gcc-c++-4.8.5-11.el7.x86_64 ---> Package gcc.x86_64 0:4.8.5-36.el7_6.2 will be an update --> Processing Dependency: cpp = 4.8.5-36.el7_6.2 for package: gcc-4.8.5-36.el7_6.2.x86_64 --> Processing Dependency: libgcc >= 4.8.5-36.el7_6.2 for package: gcc-4.8.5-36.el7_6.2.x86_64 ---> Package libgomp.x86_64 0:4.8.5-11.el7 will be updated ---> Package libgomp.x86_64 0:4.8.5-36.el7_6.2 will be an update ---> Package make.x86_64 1:3.82-21.el7 will be updated ---> Package make.x86_64 1:3.82-23.el7 will be an update ---> Package patch.x86_64 0:2.7.1-10.el7_5 will be installed ---> Package qt.x86_64 1:4.8.7-2.el7 will be installed --> Processing Dependency: qt-settings for package: 1:qt-4.8.7-2.el7.x86_64 --> Processing Dependency: libcrypto.so.10(OPENSSL_1.0.2)(64bit) for package: 1:qt-4.8.7-2.el7.x86_64 --> Running transaction check ---> Package cpp.x86_64 0:4.8.5-11.el7 will be updated ---> Package cpp.x86_64 0:4.8.5-36.el7_6.2 will be an update ---> Package elfutils-libelf-devel.x86_64 0:0.172-2.el7 will be installed --> Processing Dependency: elfutils-libelf(x86-64) = 0.172-2.el7 for package: elfutils-libelf-devel-0.172-2.el7.x86_64 ---> Package gcc-c++.x86_64 0:4.8.5-11.el7 will be updated ---> Package gcc-c++.x86_64 0:4.8.5-36.el7_6.2 will be an update --> Processing Dependency: libstdc++-devel = 4.8.5-36.el7_6.2 for package: gcc-c++-4.8.5-36.el7_6.2.x86_64 --> Processing Dependency: libstdc++ = 4.8.5-36.el7_6.2 for package: gcc-c++-4.8.5-36.el7_6.2.x86_64 ---> Package kernel-debug-devel.x86_64 0:3.10.0-957.21.3.el7 will be installed ---> Package libgcc.x86_64 0:4.8.5-11.el7 will be updated ---> Package libgcc.x86_64 0:4.8.5-36.el7_6.2 will be an update ---> Package openssl-libs.x86_64 1:1.0.1e-60.el7_3.1 will be updated --> Processing Dependency: openssl-libs(x86-64) = 1:1.0.1e-60.el7_3.1 for package: 1:openssl-1.0.1e-60.el7_3.1.x86_64 --> Processing Dependency: openssl-libs(x86-64) = 1:1.0.1e-60.el7_3.1 for package: 1:openssl-devel-1.0.1e-60.el7_3.1.x86_64 ---> Package openssl-libs.x86_64 1:1.0.2k-16.el7_6.1 will be an update ---> Package qt-settings.noarch 0:19-23.8.el7.centos will be installed --> Running transaction check ---> Package elfutils-libelf.x86_64 0:0.160-1.el7 will be updated --> Processing Dependency: elfutils-libelf(x86-64) = 0.160-1.el7 for package: elfutils-libs-0.160-1.el7.x86_64 --> Processing Dependency: elfutils-libelf(x86-64) = 0.160-1.el7 for package: elfutils-0.160-1.el7.x86_64 ---> Package elfutils-libelf.x86_64 0:0.172-2.el7 will be an update ---> Package libstdc++.x86_64 0:4.8.5-11.el7 will be updated ---> Package libstdc++.x86_64 0:4.8.5-36.el7_6.2 will be an update ---> Package libstdc++-devel.x86_64 0:4.8.5-11.el7 will be updated ---> Package libstdc++-devel.x86_64 0:4.8.5-36.el7_6.2 will be an update ---> Package openssl.x86_64 1:1.0.1e-60.el7_3.1 will be updated ---> Package openssl.x86_64 1:1.0.2k-16.el7_6.1 will be an update ---> Package openssl-devel.x86_64 1:1.0.1e-60.el7_3.1 will be updated ---> Package openssl-devel.x86_64 1:1.0.2k-16.el7_6.1 will be an update --> Running transaction check ---> Package elfutils.x86_64 0:0.160-1.el7 will be updated ---> Package elfutils.x86_64 0:0.172-2.el7 will be an update ---> Package elfutils-libs.x86_64 0:0.160-1.el7 will be updated ---> Package elfutils-libs.x86_64 0:0.172-2.el7 will be an update --> Processing Dependency: default-yama-scope for package: elfutils-libs-0.172-2.el7.x86_64 --> Running transaction check ---> Package elfutils-default-yama-scope.noarch 0:0.172-2.el7 will be installed --> Finished Dependency Resolution
Dependencies Resolved
=============================================================================================================================================================================================================================================================================== Package Arch Version Repository Size =============================================================================================================================================================================================================================================================================== Installing: dkms noarch 2.4.0-1.20170926git959bd74.el6 epel 78 k patch x86_64 2.7.1-10.el7_5 base 110 k qt x86_64 1:4.8.7-2.el7 base 4.6 M Updating: gcc x86_64 4.8.5-36.el7_6.2 updates 16 M libgomp x86_64 4.8.5-36.el7_6.2 updates 158 k make x86_64 1:3.82-23.el7 base 420 k Installing for dependencies: elfutils-default-yama-scope noarch 0.172-2.el7 base 32 k elfutils-libelf-devel x86_64 0.172-2.el7 base 39 k kernel-debug-devel x86_64 3.10.0-957.21.3.el7 updates 17 M qt-settings noarch 19-23.8.el7.centos base 17 k Updating for dependencies: cpp x86_64 4.8.5-36.el7_6.2 updates 5.9 M elfutils x86_64 0.172-2.el7 base 299 k elfutils-libelf x86_64 0.172-2.el7 base 194 k elfutils-libs x86_64 0.172-2.el7 base 285 k gcc-c++ x86_64 4.8.5-36.el7_6.2 updates 7.2 M libgcc x86_64 4.8.5-36.el7_6.2 updates 102 k libstdc++ x86_64 4.8.5-36.el7_6.2 updates 305 k libstdc++-devel x86_64 4.8.5-36.el7_6.2 updates 1.5 M openssl x86_64 1:1.0.2k-16.el7_6.1 updates 493 k openssl-devel x86_64 1:1.0.2k-16.el7_6.1 updates 1.5 M openssl-libs x86_64 1:1.0.2k-16.el7_6.1 updates 1.2 M
[root@localhost devops]# yum -y install kernel-headers kernel-devel binutils glibc-headers glibc-devel font-forge Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: centos.mirror.moack.net * extras: data.aonenetworks.kr * updates: mirror.kakao.com * webtatic: us-east.repo.webtatic.com No package font-forge available. Resolving Dependencies --> Running transaction check ---> Package binutils.x86_64 0:2.23.52.0.1-30.el7 will be updated ---> Package binutils.x86_64 0:2.27-34.base.el7 will be an update ---> Package glibc-devel.x86_64 0:2.17-157.el7_3.1 will be updated ---> Package glibc-devel.x86_64 0:2.17-260.el7_6.5 will be an update --> Processing Dependency: glibc = 2.17-260.el7_6.5 for package: glibc-devel-2.17-260.el7_6.5.x86_64 ---> Package glibc-headers.x86_64 0:2.17-157.el7_3.1 will be updated ---> Package glibc-headers.x86_64 0:2.17-260.el7_6.5 will be an update ---> Package kernel-devel.x86_64 0:3.10.0-957.21.3.el7 will be installed ---> Package kernel-headers.x86_64 0:3.10.0-514.10.2.el7 will be updated ---> Package kernel-headers.x86_64 0:3.10.0-957.21.3.el7 will be an update --> Running transaction check ---> Package glibc.x86_64 0:2.17-157.el7_3.1 will be updated --> Processing Dependency: glibc = 2.17-157.el7_3.1 for package: glibc-common-2.17-157.el7_3.1.x86_64 ---> Package glibc.x86_64 0:2.17-260.el7_6.5 will be an update --> Running transaction check ---> Package glibc-common.x86_64 0:2.17-157.el7_3.1 will be updated ---> Package glibc-common.x86_64 0:2.17-260.el7_6.5 will be an update --> Finished Dependency Resolution
Dependencies Resolved
=============================================================================================================================================================================================================================================================================== Package Arch Version Repository Size =============================================================================================================================================================================================================================================================================== Installing: kernel-devel x86_64 3.10.0-957.21.3.el7 updates 17 M Updating: binutils x86_64 2.27-34.base.el7 base 5.9 M glibc-devel x86_64 2.17-260.el7_6.5 updates 1.1 M glibc-headers x86_64 2.17-260.el7_6.5 updates 683 k kernel-headers x86_64 3.10.0-957.21.3.el7 updates 8.0 M Updating for dependencies: glibc x86_64 2.17-260.el7_6.5 updates 3.7 M glibc-common x86_64 2.17-260.el7_6.5 updates 12 M
[root@localhost devops]# cd /etc/yum.repos.d/ [root@localhost yum.repos.d]# ls CentOS-Base.repo CentOS-CR.repo CentOS-Debuginfo.repo CentOS-Sources.repo CentOS-Vault.repo CentOS-fasttrack.repo docker-ce.repo epel-testing.repo epel.repo mariadb.repo webtatic-archive.repo webtatic-testing.repo webtatic.repo [root@localhost yum.repos.d]# ll 합계 52 -rw-r--r--. 1 root root 1664 4월 1 2015 CentOS-Base.repo -rw-r--r--. 1 root root 1309 4월 1 2015 CentOS-CR.repo -rw-r--r--. 1 root root 649 4월 1 2015 CentOS-Debuginfo.repo -rw-r--r--. 1 root root 1331 4월 1 2015 CentOS-Sources.repo -rw-r--r--. 1 root root 1002 4월 1 2015 CentOS-Vault.repo -rw-r--r--. 1 root root 290 4월 1 2015 CentOS-fasttrack.repo -rw-r--r--. 1 root root 2424 10월 25 2018 docker-ce.repo -rw-r--r--. 1 root root 1056 11월 5 2012 epel-testing.repo -rw-r--r--. 1 root root 960 6월 20 12:28 epel.repo -rw-r--r--. 1 root root 139 2월 24 2017 mariadb.repo -rw-r--r--. 1 root root 963 11월 13 2016 webtatic-archive.repo -rw-r--r--. 1 root root 963 11월 13 2016 webtatic-testing.repo -rw-r--r--. 1 root root 865 11월 13 2016 webtatic.repo [root@localhost yum.repos.d]# wget http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo --2019-06-21 11:04:18-- http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo Resolving download.virtualbox.org (download.virtualbox.org)... 23.35.220.157 Connecting to download.virtualbox.org (download.virtualbox.org)|23.35.220.157|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 259 [text/plain] Saving to: ‘virtualbox.repo’
100%[=====================================================================================================================================================================================================================================>] 259 --.-K/s in 0s
Total download size: 116 M Installed size: 238 M Downloading packages: 경고: /var/cache/yum/x86_64/7/virtualbox/packages/VirtualBox-6.0-6.0.8_130520_el7-1.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 98ab5139: NOKEY========================================================================================-] 8.1 MB/s | 116 MB 00:00:00 ETA Public key for VirtualBox-6.0-6.0.8_130520_el7-1.x86_64.rpm is not installed VirtualBox-6.0-6.0.8_130520_el7-1.x86_64.rpm | 116 MB 00:00:14 Retrieving key from https://www.virtualbox.org/download/oracle_vbox.asc Importing GPG key 0x98AB5139: Userid : "Oracle Corporation (VirtualBox archive signing key) <info@virtualbox.org>" Fingerprint: 7b0f ab3a 13b9 0743 5925 d9c9 5442 2a4b 98ab 5139 From : https://www.virtualbox.org/download/oracle_vbox.asc Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : VirtualBox-6.0-6.0.8_130520_el7-1.x86_64 1/1
Creating group 'vboxusers'. VM users must be member of that group!
This system is currently not set up to build kernel modules. Please install the Linux kernel "header" files matching the current kernel for adding new hardware support to the system. The distribution packages containing the headers are probably: kernel-devel kernel-devel-3.10.0-229.el7.x86_64 This system is currently not set up to build kernel modules. Please install the Linux kernel "header" files matching the current kernel for adding new hardware support to the system. The distribution packages containing the headers are probably: kernel-devel kernel-devel-3.10.0-229.el7.x86_64
There were problems setting up VirtualBox. To re-start the set-up process, run /sbin/vboxconfig as root. If your system is using EFI Secure Boot you may need to sign the kernel modules (vboxdrv, vboxnetflt, vboxnetadp, vboxpci) before you can load them. Please see your Linux system's documentation for more information. Verifying : VirtualBox-6.0-6.0.8_130520_el7-1.x86_64 1/1 Installed: VirtualBox-6.0.x86_64 0:6.0.8_130520_el7-1 Complete!
[root@localhost yum.repos.d]# rcvboxdrv setup vboxdrv.sh: Stopping VirtualBox services. vboxdrv.sh: Starting VirtualBox services. vboxdrv.sh: Building VirtualBox kernel modules. This system is currently not set up to build kernel modules. Please install the Linux kernel "header" files matching the current kernel for adding new hardware support to the system. The distribution packages containing the headers are probably: kernel-devel kernel-devel-3.10.0-957.el7.x86_64
상위와 같이 virtual box를 셋업 했을 경우
Please install the Linux kernel "header" files matching the current kernel
================================================================================================================================================================================================================== Package Arch Version Repository Size ================================================================================================================================================================================================================== Installing: kernel-devel x86_64 3.10.0-957.el7 base 17 M
Total download size: 17 M Installed size: 37 M Is this ok [y/d/N]: y Downloading packages: No Presto metadata available for base kernel-devel-3.10.0-957.el7.x86_64.rpm | 17 MB 00:00:01 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : kernel-devel-3.10.0-957.el7.x86_64 1/1 Verifying : kernel-devel-3.10.0-957.el7.x86_64 1/1
Total size: 190 M Installed size: 190 M Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : 1:vagrant-1.9.6-1.x86_64 1/1 Verifying : 1:vagrant-1.9.6-1.x86_64 1/1
Installed: vagrant.x86_64 1:1.9.6-1
Complete!
Vagrant Start
vagrant init
vagrant up
으로 최초 vagrant가 잘 install 되었는지 확인 가능하지만
Provider를 설정해달라는 요청이 나오게 되는데
vagrant up --provider=virtualbox
와 같이 provider를 설정 해주면 된다.
[root@localhost yum.repos.d]# cd ~ [root@localhost ~]# ls anaconda-ks.cfg [root@localhost ~]# mkdir vagrant [root@localhost ~]# cd vagrant/ [root@localhost vagrant]# ls [root@localhost vagrant]# vagrant init A `Vagrantfile` has been placed in this directory. You are now ready to `vagrant up` your first virtual environment! Please read the comments in the Vagrantfile as well as documentation on `vagrantup.com` for more information on using Vagrant. [root@localhost vagrant]# vagrant up No usable default provider could be found for your system.
Vagrant relies on interactions with 3rd party systems, known as "providers", to provide Vagrant with resources to run development environments. Examples are VirtualBox, VMware, Hyper-V.
The easiest solution to this message is to install VirtualBox, which is available for free on all major platforms.
If you believe you already have a provider available, make sure it is properly installed and configured. You can see more details about why a particular provider isn't working by forcing usage with `vagrant up --provider=PROVIDER`, which should give you a more specific error message for that particular provider.
centos/7이라는 box를 vagrant에 등록 해준다.
이때 default Provider를 선택하면 앞서 --provider= 옵션을 사용하지 않아도 된다.
[root@localhost vagrant]# vagrant box add centos/7 ==> box: Loading metadata for box 'centos/7' box: URL: https://vagrantcloud.com/centos/7 This box can work with multiple providers! The providers that it can work with are listed below. Please review the list and choose the provider you will be working with.
Enter your choice: 3 ==> box: Adding box 'centos/7' (v1902.01) for provider: virtualbox box: Downloading: https://vagrantcloud.com/centos/boxes/7/versions/1902.01/providers/virtualbox.box ==> box: Successfully added box 'centos/7' (v1902.01) for'virtualbox'!
vagrant init
명령어를 사용할 경우
해당 명령어를 실행한 디렉토리에
Vagrantfile이 생성되는데, VM에 대한 설정을 할 수있다.
여기에서는
config.vm.box = "centos/7" 이 부분만 수정 함으로써 기본 OS가 centos 7 버전이라는 것을 알려주었다.
# -*- mode: ruby -*- # vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure # configures the configuration version (we support older styles for # backwards compatibility). Please don't change it unless you know what # you're doing. Vagrant.configure("2") do |config| # The most common configuration options are documented and commented below. # For a complete reference, please see the online documentation at # https://docs.vagrantup.com.
# Every Vagrant development environment requires a box. You can search for # boxes at https://vagrantcloud.com/search. config.vm.box = "centos/7"
[root@localhost vagrant]# vagrant up --provider=virtualbox The provider 'virtualbox' that was requested to back the machine 'default' is reporting that it isn't usable on this system. The reason is shown below: Vagrant has detected that you have a version of VirtualBox installed that is not supported by this version of Vagrant. Please install one of the supported versions listed below to use Vagrant: 4.0, 4.1, 4.2, 4.3, 5.0, 5.1 A Vagrant update may also be available that adds support for the version you specified. Please check www.vagrantup.com/downloads.html to download the latest version. [root@localhost vagrant]# yum update vagrant Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: centos.mirror.moack.net * extras: centos.mirror.moack.net * updates: centos.mirror.moack.net No packages marked for update [root@localhost vagrant]# yum uninstall vagrant Loaded plugins: fastestmirror, langpacks No such command: uninstall. Please use /usr/bin/yum --help [root@localhost vagrant]# rm -rf /opt/vagrant/ [root@localhost vagrant]# rm -f /usr/bin/vagrant [root@localhost vagrant]# sudo wget https://releases.hashicorp.com/vagrant/2.2.4/vagrant_2.2.4_x86_64.rpm --2019-06-21 19:40:06-- https://releases.hashicorp.com/vagrant/2.2.4/vagrant_2.2.4_x86_64.rpm Resolving releases.hashicorp.com (releases.hashicorp.com)... 151.101.229.183, 2a04:4e42:36::439 Connecting to releases.hashicorp.com (releases.hashicorp.com)|151.101.229.183|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 40824607 (39M) [application/x-redhat-package-manager] Saving to: ‘vagrant_2.2.4_x86_64.rpm’ 100%[========================================================================================================================================================================>] 40,824,607 9.96MB/s in 4.7s 2019-06-21 19:40:12 (8.20 MB/s) - ‘vagrant_2.2.4_x86_64.rpm’ saved [40824607/40824607] [root@localhost vagrant]# vagrant --version bash: /usr/bin/vagrant: 그런 파일이나 디렉터리가 없습니다 [root@localhost vagrant]# vagrnat bash: vagrnat: 명령을 찾을 수 없습니다... [root@localhost vagrant]# ls Vagrantfile vagrant_2.2.4_x86_64.rpm [root@localhost vagrant]# sudo yum localinstall vagrant_2.2.4_x86_64.rpm Loaded plugins: fastestmirror, langpacks Examining vagrant_2.2.4_x86_64.rpm: 1:vagrant-2.2.4-1.x86_64 Marking vagrant_2.2.4_x86_64.rpm as an update to 1:vagrant-1.9.6-1.x86_64 Resolving Dependencies --> Running transaction check ---> Package vagrant.x86_64 1:1.9.6-1 will be updated ---> Package vagrant.x86_64 1:2.2.4-1 will be an update --> Finished Dependency Resolution Dependencies Resolved ================================================================================================================================================================================================================== Package Arch Version Repository Size ================================================================================================================================================================================================================== Updating: vagrant x86_64 1:2.2.4-1 /vagrant_2.2.4_x86_64 110 M Transaction Summary ================================================================================================================================================================================================================== Upgrade 1 Package Total size: 110 M Is this ok [y/d/N]: y Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Updating : 1:vagrant-2.2.4-1.x86_64 1/2 Cleanup : 1:vagrant-1.9.6-1.x86_64 2/2 경고: file /opt/vagrant/embedded/share/info/rluserman.info: remove failed: 그런 파일이나 디렉터리가 없습니다 경고: file /opt/vagrant/embedded/share/info/readline.info: remove failed: 그런 파일이나 디렉터리가 없습니다 경고: file /opt/vagrant/embedded/share/info/libffi.info: remove failed: 그런 파일이나 디렉터리가 없습니다
앞서 vagrant를 새롭게 install 하였고, 아래와 같이 centos/7을 init 해보자.
vagrant init centos/7
vagrant up
[root@localhost vagrant-centos-7]# vagrant init centos/7 A `Vagrantfile` has been placed in this directory. You are now ready to `vagrant up` your first virtual environment! Please read the comments in the Vagrantfile as well as documentation on `vagrantup.com` for more information on using Vagrant. [root@localhost vagrant-centos-7]# vagrant up
Bringing machine 'default' up with 'virtualbox' provider... ==> default: Importing base box 'centos/7'... ==> default: Matching MAC address for NAT networking... ==> default: Checking if box 'centos/7' version '1902.01' is up to date... ==> default: Setting the name of the VM: vagrant-centos-7_default_1561113935045_2937 ==> default: Clearing any previously set network interfaces... ==> default: Preparing network interfaces based on configuration... default: Adapter 1: nat ==> default: Forwarding ports... default: 22 (guest) => 2222 (host) (adapter 1) ==> default: Booting VM... ==> default: Waiting for machine to boot. This may take a few minutes... default: SSH address: 127.0.0.1:2222 default: SSH username: vagrant default: SSH auth method: private key default: default: Vagrant insecure key detected. Vagrant will automatically replace default: this with a newly generated keypair for better security. default: default: Inserting generated public key within guest... default: Removing insecure key from the guest if it's present... default: Key inserted! Disconnecting and reconnecting using new SSH key... ==> default: Machine booted and ready! ==> default: Checking for guest additions in VM... default: No guest additions were detected on the base box for this VM! Guest default: additions are required for forwarded ports, shared folders, host only default: networking, and more. If SSH fails on this machine, please install default: the guest additions and repackage the box to continue. default: default: This is not an error message; everything may continue to work properly, default: in which case you may ignore this message. ==> default: Rsyncing folder: /root/vagrant-centos-7/ => /vagrant
상위와 같이 로그가 나왔다면, 성공적으로 virtual box, vagrant가 install 된것이다.