Skip to content

terrafromを使ってproxmoxでvyosのLTSを自動でビルドできるVMを立てる

Notifications You must be signed in to change notification settings

Till0196/proxmox-vyos-jenkins

Repository files navigation

Proxmox Vyos Jenkins

Proxmoxにterraformを用いて、vyosのLTSビルドに必要なパッケージをビルドできる仮想マシンを自動で構築します。

iso生成とcloudinitが使えるcloudimageを生成するjobもJenkinsに追加します。

利用可能なVyosのLTSバージョン

  • sagitta (1.4)
  • equuleus (1.3)

terraform modules

  • proxmox-cloud-image

    Proxmoxノードにclouimageをダウンロードして、ファイルを生成します。

    node_namesはリスト型を受け付けます。 data.proxmox_virtual_environment_nodesでノード情報を取得し、その情報からnodeを登録しています。

    複数のProxmoxからなるProxmoxクラスターになっている場合、全てのProxmoxクラスターにイメージが追加されます。 特定のProxmoxノードにだけイメージをダウンロードしたい場合、node_names = [ "pve" ]のようにリスト型でノード名を指定することで実現できます。

    後述するproxmox-cloud-imageは単一ノードでの実行を前提としているため、仮想マシンを構築しない使用しないノードであってもcloud-imageが登録されます。

  • proxmox-cloud-image-vm

    proxmox-cloud-imageでダウンロードしたcloud-imageとcloud-initを用いてUbuntu24.04をセットアップします。

    isoからcloud-imageファイルを作成するvyos-packerでqemuによるKVMを利用できるようにするため、cpu_type = hostである必要があります。

    また、ProxmoxノードもKVMのネストが有効化されている必要があります。Proxmoxの最近のバージョンでは初期設定で有効化されています。

scripts

  • vyos-jenkins-automate-setting-wave1.sh

    dd010101/vyos-jenkinsのstage1-4まで実行し、Jenkinsをセットアップします。

    stage2(2-jenkins.sh)に対話が必要な部分がありますが、expectと補助スクリプト(jenkins-setup-helper-scripts)を用いて自動化しています。

    adminユーザーのパスワードはterrarform内のjenkins_admin_passwordで設定した値が利用されます。

    値が指定されていない場合、passwordがパスワードとして設定されます。

    このスクリプト内の実行まではterraform_dataリソースで実行されます。

  • vyos-jenkins-automate-setting-wave2.sh

    vyos-jenkins-automate-setting-wave1.shの最後に別のpidで呼び出されるスクリプトです。

    terraformの実行時間があまりにも長くなるため、このような構成になっています。

    このスクリプトがやることはdd010101/vyos-jenkinsの残りのstageを実行し、最後にvyos-jenkins-add-build-image-job.shを実行します。

  • vyos-jenkins-add-build-image-job.sh

    vyosのisoをビルドするJenkinsのjobを登録するスクリプトです。

    vyos-jenkins-automate-setting-wave1.sh内でダウンロードされたjenkins-cliとクレデンシャルを利用してjobを追加します。

    追加されるjobは下記の通りです。

    • build-vyos-iso-equuleus

      ビルドされたパッケージを利用してバージョンequuleus(1.3)のisoファイルを生成します。

      実行には該当バージョンの全てのパッケージが正常にビルドされている必要があります。

    • build-vyos-iso-sagitta

      ビルドされたパッケージを利用してバージョンsagitta(1.4)のisoファイルを生成します。

      実行には該当バージョンの全てのパッケージが正常にビルドされている必要があります。

    • build-vyos-cloudimage-equuleus

      build-vyos-iso-equuleusjobによって生成されたisoを使って、cloudinitが利用できるcloudimageをpackerで生成します。

      packerでの処理はvyos-contrib/packer-vyosに依存しています。

      実行にはbuild-vyos-iso-equuleusjobが正常にisoを生成されている必要があります。

    • build-vyos-cloudimage-sagitta

      build-vyos-iso-sagittajobによって生成されたisoを使って、cloudinitが利用できるcloudimageを生成します。

      packerでの処理はvyos-contrib/packer-vyosに依存しています。

      実行にはbuild-vyos-iso-sagittajobが正常にisoを生成されている必要があります。

terraform-docsについて

READMEにterraform-docsを利用しています。

terraform-docsをインストールし、下記コマンドをレポジトリ直下で実行すると最新の情報に更新されます。

terraform-docs -c .terraform-docs.yml --recursive .

pre-commitがインストールされている環境の場合は、コミット時に自動で更新と作成が行われます。

Requirements

Name Version
terraform >= 1.3.3
proxmox 0.54.0
tls 4.0.5

Providers

Name Version
proxmox 0.54.0
terraform n/a
tls 4.0.5

Modules

Name Source Version
proxmox_cloud_image ./modules/proxmox-cloud-image n/a
proxmox_cloud_image_vm ./modules/proxmox-cloud-image-vm n/a

Resources

Name Type
terraform_data.setup_vyos_jenkins resource
tls_private_key.ssh_private_key resource
proxmox_virtual_environment_nodes.nodes data source

Inputs

Name Description Type Default Required
cpu The number of CPUs for the VM number n/a yes
disk_size The disk size for the VM number n/a yes
fqdn The FQDN of the VM string n/a yes
memory The amount of memory for the VM number n/a yes
pve_node_name The name of the node string n/a yes
virtual_environment_endpoint The endpoint for the Proxmox Virtual Environment API (example: https://host:port) string n/a yes
virtual_environment_password The password for the Proxmox Virtual Environment API string n/a yes
virtual_environment_ssh The SSH configuration for the Proxmox Virtual Environment
object({
node = list(object({
name = string
address = string
}))
agent = bool
username = string
password = string
})
n/a yes
virtual_environment_tls_insecure Disable TLS verification while connecting to the Proxmox VE API server. bool n/a yes
virtual_environment_username The username and realm for the Proxmox Virtual Environment API (example: root@pam) string n/a yes
vm_id The VM ID number n/a yes
vm_name The name of the VM string n/a yes
apt_mirror The APT mirror(Set and use with cloud-init) string "https://ftp.udx.icscoe.jp/Linux/ubuntu" no
bridge_name The bridge name for the VM string "vmbr0" no
cidr The CIDR for the VM string "" no
cloud_config_datastore_name The name of the datastore for the cloud config file (Content type snippets must be enabled) string "local" no
cpu_type The CPU type for the VM (packer qemu only works host type) string "host" no
dhcp Use DHCP for the IP address bool false no
dns_servers The DNS servers list(string)
[
"1.1.1.1",
"8.8.8.8"
]
no
gateway The gateway address for the VM string "" no
ip The IP address for the VM string "" no
jenkins_admin_password The Jenkins admin password string "password" no
locale The locale(Set and use with cloud-init) string "en_US.UTF-8" no
on_boot Start the VM on PVE node boot bool true no
os_datastore_lvm_name The OS datastore LVM name string "local-lvm" no
ssh_pwauth Enable password authentication bool false no
timezone The timezone(Set and use with cloud-init) string "Asia/Tokyo" no
vm_tags The tags for the VM list(string)
[
"terraform-managed"
]
no
vm_user The VM user string "ubuntu" no
vm_user_password The VM user password string "password" no

Outputs

Name Description
proxmox_cloud_image downloaded cloud image file IDs and node names
proxmox_cloud_image_vm created cloud image VM

About

terrafromを使ってproxmoxでvyosのLTSを自動でビルドできるVMを立てる

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published