티스토리 뷰

Ansible

Ansible 환경 변수 / DB 연동

looeon 2024. 2. 8. 11:27

 

시작 전 복습

▶ 참조 순서

설정파일을 참조하는 순서는 현재디렉토리의 ansible.cfg 를 가장 먼저 참조

두번째는 $HOME/.ansible.cfg

마지막으로 /etc/ansible/ansible.cfg 참조

* $ANSIBLE_CONFIG 환경변수를 사용할수도 있다.

(설정파일보다 환경변수를 가장먼저 참조한다)

리눅스는 개인 설정 파일에는 . 을 붙인다 >> 관례상
[devops@control ~]$ ls -a
.  ..  .ansible  .bash_history  .bash_logout  .bash_profile
.bashrc  node_test.sh  .ssh  test  .viminfo

 

>> bashrc 는 시스템 설정 파일이므로 . 이 존재하지 않는다

[devops@control ~]$ ls /etc/bashrc
/etc/bashrc

 

▦ 한번에 ansible 로 종료 하려할 때

>> 권한이 없다 ( test 디렉터리에 권한 root로 설정하는 설정파일 존재 )

[devops@control ~]$ ansible all -m command -a 'poweroff'
node1.example.com | FAILED | rc=2 >>
[Errno 2] No such file or directory
node3.example.com | FAILED | rc=2 >>
[Errno 2] No such file or directory
node2.example.com | FAILED | rc=2 >>
[Errno 2] No such file or directory
[devops@control test]$ ansible all -m command -a 'poweroff'
node2 | FAILED | rc=-1 >>
Failed to connect to the host via ssh: ssh_exchange_identification: read: Connection reset by peer
node3 | FAILED | rc=-1 >>
Failed to connect to the host via ssh: ssh: connect to host node3 port 22: Connection refused
node1 | FAILED | rc=-1 >>
Failed to connect to the host via ssh: ssh: connect to host node1 port 22: Connection refused

 

▶ centOS 9 다운로드

# --- apm Server ---
Vagrant.configure("2") do |config|
	config.vm.define "apm-server" do |cfg|
		cfg.vm.box = "generic/centos9s"
		cfg.vm.provider "virtualbox" do |vb|
			vb.name = "apm-server"
			vb.cpus = 2
			vb.memory = 4096
			vb.gui = false
		end
		cfg.vm.host_name = "apm.example.com"
		cfg.vm.network "private_network", ip: "192.168.110.90"
		cfg.vm.provision "shell", path:"ssh_conf.sh"
#		cfg.vm.synced_folder "../data","/vagrant",disabled: true
	end
end

ssh_conf.sh 는 centos 에서 썼던걸 그대로 복사

 

MariaDB
Apachie

PHP

 

[vagrant@apm ~]$ sudo yum -y install mariadb
[vagrant@apm ~]$ sudo yum -y install php php-mysqlnd php-gd php-mbstring

apachie를 깔고 PHP를 깔아야 되는데 잘못해서 롤백 시킨다

[vagrant@apm ~]$ sudo dnf history
[vagrant@apm ~]$ sudo dnf history undo 9
[vagrant@apm ~]$ sudo dnf -y install httpd
[vagrant@apm ~]$ sudo yum -y install php php-mysqlnd php-gd php-mbstring

 

▶ <? ?> 로도 코드 짤 수 있도록 해야 한다

하나가 출력 안됨

 

▷ /etc/php.ini 에서 설정파일

>> Short_open_tag 를 Off >> On으로 변경

둘다 출력된다

 

 

▷/etc/httpd/httpd.conf

>> 위치 확인

module 확인하고 수정하기 위해 필요

 

▷ /etc/httpd/conf.d/php.conf >> 에서 모듈을 수정할거면 수정??

 

▷index.html이 없으면 index.php 가 출력된다 >> 설정파일에서 확인 가능

 

 

▷http://192.168.110.90 접속시 제대로 출력이 되지 않아서 에러 설정 보이도록 설정

[root@apm html]# systemctl restart php-fpm.service

 

▶ 태그

https://www.w3schools.com/

 

W3Schools Online Web Tutorials

W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.

www.w3schools.com

 

▷ Forms 는 데이터를 보내는 것이라 생각

>> 간단한 form 작성

 

 

 

 

▷ url encoding

ip/소스파일?key=value&key=value
홍 길동 ==> 홍+길동	%%nn%%nn%%nn

 

▶ Superglobals 변수 >> 전역변수 ( PHP 전반에 영향 )

>> 주로 $_ 로 시작하는 변수

$GLOBALS
$_SERVER
$_REQUEST
$_POST
$_GET
$_FILES
$_ENV
$_COOKIE
$_SESSION

 

▷ 전역변수 설정

 

 

 

>> var_dump 쓰면 변수를 출력

var_dump 로 확인한 것
display.php
0.00MB
form.html
0.00MB

>>>> get으로 넘겨준 파일 <<<<

 

▷ POST 로 넘겨준 상태

form.html
display.php

 

>> 주소창에 비밀번호 등 내용이 뜨지 않는다 POST 방식

display.php
0.00MB
form.html
0.00MB

>>>> POST <<<<

 

 

▷계산 곱셈으로 만들어보기

 

 

 

 

 

'Ansible' 카테고리의 다른 글

Ansible module  (0) 2024.02.13
Visual Studio Code  (0) 2024.02.08
yaml syntax  (0) 2024.02.07
Ansible 의 기본 동작  (0) 2024.02.07
공개키 옛날처럼 전달 / PGP,GPG  (0) 2024.02.07
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2025/03   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31
글 보관함