- ユーザをホームディレクトリごと削除するなら
userdel -r <USERNAME> rpm -ql nginxと打てば、nginxにまつわるディレクトリやファイルのパスが一覧表示される。rpm -qi nginxと打てば、nginxのパッケージ情報が表示される。- 名前、バージョン、ベンダ、プロジェクトURL、Summary, Description、RPM元 等等
rpm -qaでインストールしたパッケージが一覧表示されるrpm -qa nginxと打てば、インストール済みであればnginx等のパッケージの存在が確認できる。- 内部的にはgrep的なことをやっているのかな…?
- rpmのオプションqはqueryの略称なので、データベースへアクセスして検索してきてるイメージを持っている。
- 座学でデータベースの本を読んでいるが、
-qaと打った時に、どのような方式でアクセスしているのかを知りたくなってきた。
Last active
December 18, 2015 17:39
-
-
Save hfm/5820097 to your computer and use it in GitHub Desktop.
https://gist.github.com/Tacahilo/5795684 の続きです。
puppet manifestで前回の構成内容を再現するまでに行った作業記録です。
次のコマンドを実行すると、Rubyも依存関係から同時にインストールできる(-yは付けずに、何が入るのかはちゃんと確認)。
$ sudo yum install rubygems
Installed:
rubygems.noarch 0:1.3.7-1.el6
Dependency Installed:
compat-readline5.x86_64 0:5.2-17.1.el6 ruby.x86_64 0:1.8.7.352-10.el6_4
ruby-irb.x86_64 0:1.8.7.352-10.el6_4 ruby-libs.x86_64 0:1.8.7.352-10.el6_4
ruby-rdoc.x86_64 0:1.8.7.352-10.el6_4
Complete!
$ which gem
/usr/bin/gem
v('.')v
とりあえず自分が入れるツールのバージョンは事前に確認する(こわい)
$ gem search -r puppet | grep -e "^puppet\s"
puppet (3.2.2)
ver.3.2.2とわかって(gemにちゃんと存在することも確認出来て)落ち着きを得られたので、インストールする。
Production環境に不要なファイルを増やさないために、 --no-ri --no-rdoc を入れておく。
$ sudo gem install puppet --no-ri --no-rdoc
[sudo] password for hfm:
Successfully installed facter-1.7.1
Successfully installed json_pure-1.8.0
Successfully installed hiera-1.2.1
Successfully installed rgen-0.6.5
Successfully installed puppet-3.2.2
5 gems installed
v('.')v
まずはHello Worldが出来ているかをちゃんと確認する。
$ cd
$ mkdir -p puppet/
$ vi pupper/sample_app.pp
notice('Hello, World!')
$ puppet apply puppet/sample_app.pp
Notice: Scope(Class[main]): Hello, World!
Notice: Finished catalog run in 0.06 seconds
v('.')v
minimalにinstallしていく。
$ mkdir -p puppet/packages
$ vi puppet/packages/zsh.pp
$ puppet apply puppet/packages/zsh.pp
Error: Could not prefetch package provider 'yum': The yum provider can only be used as root
Error: Execution of '/usr/bin/yum -d 0 -e 0 -y install zsh' returned 1: You need to be root to perform this command.
Error: /Stage[main]//Package[zsh]/ensure: change from absent to present failed: Execution of '/usr/bin/yum -d 0 -e 0 -y install zsh' returned 1: You need to be root to perform this command.
Notice: Finished catalog run in 1.88 seconds
マジギレされた。
裏側でyumが呼ばれているので、sudoを付けないとダメ。 当たり前のところにボコンボコンハマってしまっていて、まだまだシステム(OS)を把握しきれていないことを痛感。
$ sudo puppet apply puppet/packages/zsh.pp
[sudo] password for hfm:
Notice: /Stage[main]//Package[zsh]/ensure: created
Notice: Finished catalog run in 9.28 seconds
$ which zsh
/bin/zsh
v('.')v
~/puppet/packages/www_and_db.pp に次の内容を書いて、nginxとmysqlをインストールする。
$packages = [
'nginx',
'mysql',
'mysql-server'
]
package { $packages:
ensure => installed
}
先程と同様に puppet apply 。
$ sudo puppet apply puppet/packages/www_and_db.pp
Notice: /Stage[main]//Package[nginx]/ensure: created
Notice: /Stage[main]//Package[mysql-server]/ensure: created
Notice: Finished catalog run in 30.51 seconds
$ rpm -qa nginx mysql
nginx-1.0.15-5.el6.x86_64
mysql-5.1.69-1.el6_4.x86_64
v('.')v
次のマニフェストを作成
$packages = [
'git',
'mysql-devel',
'mysql-server',
'nginx',
'zsh'
]
package { $packages:
ensure => installed
}
user { 'okkun':
ensure => present,
comment => 'app001',
home => '/home/okkun',
managehome => true,
shell => '/bin/zsh',
uid => 1000,
gid => 1000
}
group { 'appuser':
ensure => present,
gid => 1000
}
service { 'nginx':
ensure => running,
enable => true,
hasrestart => true,
require => File['/etc/nginx/nginx.conf'],
subscribe => File['/etc/nginx/nginx.conf']
}
file { '/etc/nginx/nginx.conf':
ensure => present,
owner => root,
group => root,
mode => '0644',
content => template('nginx.conf'),
require => Package['nginx'],
notify => Service['nginx']
}
file { '/etc/nginx/conf.d/rails.conf':
ensure => present,
owner => root,
group => root,
mode => '0644',
content => template('rails.conf'),
require => Package['nginx'],
notify => Service['nginx']
}
service { 'mysqld':
ensure => running,
enable => true,
hasrestart => true
}
実行。 --verbose をつけて挙動を細かくチェック。
$ sudo puppet apply --verbose puppet/sample_app.pp
Info: Applying configuration version '1371714805'
Notice: /Stage[main]//Package[git]/ensure: created
Notice: /Stage[main]//Group[appuser]/ensure: created
Info: FileBucket adding {md5}d9dfc198c249bb4ac341198a752b9458
Info: /Stage[main]//File[/etc/nginx/nginx.conf]: Filebucketed /etc/nginx/nginx.conf to puppet with sum d9dfc198c249bb4ac341198a752b9458
Notice: /Stage[main]//File[/etc/nginx/nginx.conf]/content: content changed '{md5}d9dfc198c249bb4ac341198a752b9458' to '{md5}e674b26b046cbf2c8323f6a0a997235f'
Info: /Stage[main]//File[/etc/nginx/nginx.conf]: Scheduling refresh of Service[nginx]
Info: /Stage[main]//File[/etc/nginx/nginx.conf]: Scheduling refresh of Service[nginx]
Notice: /Stage[main]//Package[mysql-devel]/ensure: created
Notice: /Stage[main]//Service[mysqld]/ensure: ensure changed 'stopped' to 'running'
Info: /Stage[main]//Service[mysqld]: Unscheduling refresh on Service[mysqld]
Notice: /Stage[main]//User[okkun]/ensure: created
Notice: /Stage[main]//File[/etc/nginx/conf.d/rails.conf]/ensure: created
Info: /Stage[main]//File[/etc/nginx/conf.d/rails.conf]: Scheduling refresh of Service[nginx]
Notice: /Stage[main]//Service[nginx]/ensure: ensure changed 'stopped' to 'running'
Info: /Stage[main]//Service[nginx]: Unscheduling refresh on Service[nginx]
Notice: Finished catalog run in 42.46 seconds
既にインストール済みだったnginxはそのままで、重複なく設定ファイルだけが更新されたv('.')v
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment