packerで複数NICなqemuイメージを作成する

packerで複数NICなqmuイメージをkickstartで作成するのに苦労したのでメモ

これが参考になった stackoverflow.com

qemuargsでmac addressを指定してるのは出来たイメージをkvmにインポートする時にブリッジを指定したかったから。

     "qemuargs": [ 
        [ "-serial", "file:serial.out" ],
    [ "-netdev", "user,id=net0,hostfwd=tcp::2222-:22,hostfwd=tcp::2223-:22,net=10.0.2.0/24" ],
        [ "-device", "virtio-net,netdev=net0,mac=52:54:00:12:34:56" ],
    [ "-netdev", "user,id=net1" ],
        [ "-device", "virtio-net-pci,netdev=net1,mac=52:54:01:12:34:56" ]
      ],
      "boot_command":
      [
        "<tab>",
        " append console=ttyS0,115200n8 ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/centos6-ks.cfg ksdevice=eth0",
        "<enter>"
      ]

eth0はprovisionersのshellで設定。 eth1はkickstartで設定した。

kvmへのインポートはこんな感じで。

virt-install --memory 2048 --name test --disk /var/lib/libvirt/qemu/test --network bridge:br0 --mac=52:54:00:12:34:56 --network bridge:br1 --mac=52:54:01:12:34:56 --import

CentOS 7なsystemd環境でautologinする

KVMでauto loginできたらと調べて上手くできたのでメモ

cp /usr/lib/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@ttyS0.service

diff -Nurr /usr/lib/systemd/system/getty\@.service getty\@ttyS0.service 
--- /usr/lib/systemd/system/getty@.service      2014-10-23 20:29:59.000000000 +0900
+++ getty@ttyS0.service 2014-12-01 14:39:07.338000000 +0900
@@ -25,7 +25,7 @@
 
 [Service]
 # the VT is cleared by TTYVTDisallocate
-ExecStart=-/sbin/agetty --noclear %I
+ExecStart=-/sbin/agetty --autologin root --noclear %I
 Type=idle
 Restart=always
 RestartSec=0
@@ -44,3 +44,4 @@
 
 [Install]
 WantedBy=getty.target
+;Alias=getty@ttyS0.service


これだけだとうまく動かないので追加
[https://wiki.archlinux.org/index.php/automatic_login_to_virtual_console:title]


後で調べる。

nginxをwildcard SSLを使ってSSLアクセラレータとして設定した時のメモ

同じドメインなのにSSLを使うとIPも必要だし何かいい方法ないかと考えた時に思いついた。 default.confをこんな感じで設定したらIPを消費しないで済んだし良かった。 upstream は別ファイルで管理した。

ssl_certificate     /etc/pki/tls/certs/wildcard.example.com.crt;
ssl_certificate_key         /etc/pki/tls/private/wildcard.example.com.key;
ssl_protocols         TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers RC4:HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
ssl_session_cache    shared:SSL:10m;
ssl_session_timeout  10m;

proxy_next_upstream error timeout;
proxy_set_header Host              $host;
proxy_set_header X-Real-IP         $remote_addr;
proxy_set_header X-Forwarded-For   $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port  $remote_port;
port_in_redirect                   off;
add_header      Front-End-Https    on;

server {
    listen    80;
    listen    443 ssl spdy;
    server_name  aaa.example.com;
                location / {
                                proxy_pass http://aaa;
                }
}

server {
    listen    80;
    listen    443 ssl spdy;
    server_name bbb.example.com;
                location / {
                                proxy_pass http://bbb;
                }
}

server {
     listen    80;
     listen    443 ssl spdy;
     server_name ccc.example.com;
                location / {
                                proxy_pass http://ccc;
                } 
}

server {
    listen    80;
    listen    443 ssl spdy;
    server_name  ddd.example.com;
                location / {
                                proxy_pass http://ddd;
                }
}