From 6e72a2d3766b41fb9b2d930b5353580128eed151 Mon Sep 17 00:00:00 2001 From: Yasufumi Ogawa Date: Wed, 9 Nov 2022 16:51:56 +0900 Subject: [PATCH] Add jammy support for tacker installer As one of the community-wide goals, devstack has shifted to Ubuntu Jammy from Antelope cycle [1]. So, add playbooks for Jammy to installer. Although Focal support is still remained so that you can setup your environment on older version, but will be removed later. There are some additional updates. * Add bento as supported boxes which are well maintained more. * Use experimental Vagrant Disk to expand disk space on logical volume because for Ubuntu images of bento. * Change to use ssh key in ed25519 instead of rsa because it was deprecated in Jammy as default. [1] https://lists.openstack.org/pipermail/openstack-discuss/2022-October/030845.html Signed-off-by: Yasufumi Ogawa Change-Id: I65b209a8ff2bd46adf2a4ee507ef7eee099d1b13 --- vagrant/devstack/README.md | 27 ++- vagrant/devstack/Vagrantfile | 99 ++++++++--- vagrant/devstack/hosts | 14 +- vagrant/devstack/lib/vd_utils.rb | 26 ++- .../controller/tasks/vim_extra_plugins.yml | 2 +- .../ubuntu-jammy/compute/tasks/basic_pkgs.yml | 6 + .../ubuntu-jammy/compute/tasks/devstack.yml | 15 ++ .../roles/ubuntu-jammy/compute/tasks/main.yml | 6 + .../compute/templates/local.conf.j2 | 22 +++ .../controller/tasks/basic_pkgs.yml | 16 ++ .../controller/tasks/devstack.yml | 20 +++ .../controller/tasks/extra_tools.yml | 8 + .../controller/tasks/git_config.yml | 4 + .../ubuntu-jammy/controller/tasks/main.yml | 23 +++ .../tasks/python3_specific_vers.yml | 16 ++ .../controller/tasks/remove_useless_pkgs.yml | 11 ++ .../controller/tasks/set_path_env.yml | 5 + .../controller/tasks/setup_tacker.yml | 65 +++++++ .../controller/tasks/vim_extra_plugins.yml | 29 ++++ .../controller/tasks/vim_latest.yml | 8 + .../controller/templates/vimrc.j2 | 159 ++++++++++++++++++ vagrant/devstack/samples/machines-2nodes.yml | 13 +- vagrant/devstack/samples/machines.yml | 10 +- vagrant/devstack/site.yaml | 12 ++ 24 files changed, 566 insertions(+), 50 deletions(-) create mode 100644 vagrant/devstack/roles/ubuntu-jammy/compute/tasks/basic_pkgs.yml create mode 100644 vagrant/devstack/roles/ubuntu-jammy/compute/tasks/devstack.yml create mode 100644 vagrant/devstack/roles/ubuntu-jammy/compute/tasks/main.yml create mode 100644 vagrant/devstack/roles/ubuntu-jammy/compute/templates/local.conf.j2 create mode 100644 vagrant/devstack/roles/ubuntu-jammy/controller/tasks/basic_pkgs.yml create mode 100644 vagrant/devstack/roles/ubuntu-jammy/controller/tasks/devstack.yml create mode 100644 vagrant/devstack/roles/ubuntu-jammy/controller/tasks/extra_tools.yml create mode 100644 vagrant/devstack/roles/ubuntu-jammy/controller/tasks/git_config.yml create mode 100644 vagrant/devstack/roles/ubuntu-jammy/controller/tasks/main.yml create mode 100644 vagrant/devstack/roles/ubuntu-jammy/controller/tasks/python3_specific_vers.yml create mode 100644 vagrant/devstack/roles/ubuntu-jammy/controller/tasks/remove_useless_pkgs.yml create mode 100644 vagrant/devstack/roles/ubuntu-jammy/controller/tasks/set_path_env.yml create mode 100644 vagrant/devstack/roles/ubuntu-jammy/controller/tasks/setup_tacker.yml create mode 100644 vagrant/devstack/roles/ubuntu-jammy/controller/tasks/vim_extra_plugins.yml create mode 100644 vagrant/devstack/roles/ubuntu-jammy/controller/tasks/vim_latest.yml create mode 100644 vagrant/devstack/roles/ubuntu-jammy/controller/templates/vimrc.j2 diff --git a/vagrant/devstack/README.md b/vagrant/devstack/README.md index 1ac3d9749..ba0142644 100644 --- a/vagrant/devstack/README.md +++ b/vagrant/devstack/README.md @@ -19,15 +19,27 @@ instructions on official sites for installation. * [vagrant](https://www.vagrantup.com/) * [ansible](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html) -Before launching your VMs, you should should install plugin `vagrant-disksize` -for expanding size of volume of VM. It is because the default size of box -provided from Ubuntu, 10GB or so, is not enough for deploying devstack -environment. It's required for expanding the volume size. +Please also notice the version of vagrant supporting experimental feature +[Vagrant Disks](https://developer.hashicorp.com/vagrant/docs/disks) for +expanding the size of volume if you use Ubuntu box image. +For other boxes than Ubuntu, plugin `vagrant-disksize` is required instead as +below. It is because the default size is not enough for deploying OpenStack +environment. ```sh $ vagrant plugin install vagrant-disksize ``` +Here is a list of current supported boxes in this tool. + +* bento/ubuntu-22.04 +* bento/ubuntu-20.04 +* ubuntu/jammy64 +* ubuntu/focal64 +* bento/centos-stream-8 +* centos/stream8 + + ### Configure and Fire Up VMs Before launching VMs with vagrant, configure `machines.yml`, which defines @@ -42,8 +54,11 @@ $ YOUR_FAVORITE_EDITOR machines.yml You should take care about `private_ips` which is used in `hosts` for `ansible-playbook` as explained later. -You should confirm you have a SSH public key before you run vagrant. If your key -is different from `~/.ssh/id_rsa.pub`, update `ssh_pub_key` in `machines.yml`. +You should confirm you have a SSH key before you run the command. This tool +expects the type of your key is not `rsa` but `ed25519` because `rsa` +was deprecated as default in Ubuntu 22.04. +Update key path `ssh_pub_key` in `machines.yml` without your key is +`~/.ssh/id_ed25519.pub`. Run `vagrant up` after configurations are done. It launches VMs and create a user `stack` on them. diff --git a/vagrant/devstack/Vagrantfile b/vagrant/devstack/Vagrantfile index 1daa13970..bb1063243 100644 --- a/vagrant/devstack/Vagrantfile +++ b/vagrant/devstack/Vagrantfile @@ -10,32 +10,38 @@ require "yaml" load "lib/machine.rb" load "lib/vd_utils.rb" +if not VdUtils.vagrant_experimentals.include?("disks") + ENV["VAGRANT_EXPERIMENTAL"] = + VdUtils.vagrant_experimentals.append("disks").join(",") +end + vd_config = YAML.load(open("machines.yml")) ssh_pub_key = VdUtils.ssh_pub_key(vd_config) machines = Machines.new(vd_config["machines"]) -# Check if you have already downloaded target box. -box_list = [] -`vagrant box list`.each_line {|l| - box_list << l.split(" ")[0] +# TODO(yasufum) Test libvirt's boxes can be deployed haven't been tested yet. +supported_boxes = { + "virtualbox" => { + "ubuntu" => ["bento/ubuntu-20.04", "bento/ubuntu-22.04", "ubuntu/focal64", "ubuntu/jammy64"], + "centos" => ["bento/centos-stream-8", "centos/stream8"] + }, + #"libvirt" => { + # "ubuntu" => ["generic/ubuntu2204", "generic/ubuntu2004"], + # "centos" => ["generic/centos9s", "generic/centos8s"] + #} } -# If you don't have the box, download it. -machines.each do |m| - if not (box_list.include? m.box) - puts "There is no box '#{m.box}' for '#{m.provider}'" - puts "Run 'vagrant box add #{m.box}' first" - end -end +lvm_boxes = ["bento/ubuntu-20.04", "bento/ubuntu-22.04"] Vagrant.configure("2") do |config| + machines.each do |machine| config.vm.define machine.hostname do |server| server.vm.box = machine.box server.vm.hostname = machine.hostname - # server.vm.box_check_update = false + #server.vm.box_check_update = false machine.private_ips.each do |ipaddr| server.vm.network "private_network", ip: ipaddr @@ -66,19 +72,20 @@ Vagrant.configure("2") do |config| end end - if Vagrant.has_plugin?("vagrant-disksize") - server.disksize.size = "#{machine.disk_size}GB" - end - - # TODO(yasufum) This configuration reported in [1] is required to avoid - # timeout for ssh login to focal64 because of setting up public key in the - # VM. This issue is only happened on focal, and not for bionic and xenial. - # Remove this config after the problem is fixed in the focal image. - # [1] https://bugs.launchpad.net/cloud-images/+bug/1829625 - if machine.box == "ubuntu/focal64" - server.vm.provider 'virtualbox' do |v| - v.customize ["modifyvm", :id, "--uart1", "0x3F8", "4"] - v.customize ["modifyvm", :id, "--uartmode1", "file", "./ttyS0.log"] + # Expand disk size for some images have not enough disk space. + # NOTE: Two scenarios are expected, having logical volumes or not. + # For lvm case, add a virtual disk with an experimental feature first, + # create a logical volume then while provisioning later. + # Add a virtual disk has arbitrary name. + # TODO(yasufum): Fix the total amount of disk size will be over + # `machine.disk_size` GB unexpectedly. + if (VdUtils.is_disks_enabled(machine.provider) and + lvm_boxes.include?(machine.box) and + supported_boxes["virtualbox"]["ubuntu"].include?(machine.box)) + server.vm.disk :disk, size: "#{machine.disk_size}GB", name: "mydrive" + else # Not a case using lvm for which just resizing. + if Vagrant.has_plugin?("vagrant-disksize") + server.disksize.size = "#{machine.disk_size}GB" end end @@ -96,8 +103,7 @@ Vagrant.configure("2") do |config| vb.memory = "#{machine.mem_size * 1024}" end - # NOTE: remove `python3-launchpadlib` which causes many warinings, and - # run autoremove to clean related packages. + # Add stack user and register ssh key for direct login with. server.vm.provision "shell", inline: <<-SHELL useradd -s /bin/bash -d /opt/stack -m stack echo "stack ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/stack @@ -112,6 +118,45 @@ Vagrant.configure("2") do |config| chown -R stack:stack /opt/stack/.ssh SHELL + # Expand disk space. + # NOTE: The name of devices and volumes are depend on the box images. + if (VdUtils.is_disks_enabled(machine.provider) and + lvm_boxes.include?(machine.box) and + supported_boxes["virtualbox"]["ubuntu"].include?(machine.box)) + server.vm.provision "shell", inline: <<-SHELL + pvcreate /dev/sdb + vgextend ubuntu-vg /dev/sdb + lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv + resize2fs /dev/ubuntu-vg/ubuntu-lv + SHELL + elsif supported_boxes["virtualbox"]["centos"].include?(machine.box) + # Use `parted` and `xfs_growfs` to expand disk space after resizing + # volume. + # NOTE: Decide partition number which is different on each box first. + if machine.box == "bento/centos-stream-8" + part_num = 2 + elsif machine.box == "centos/stream8" + part_num = 1 + end + + # NOTE: It doesn't use `parted` with --script option but here doc for + # interactive mode. It's because `resizepart` of `parted` doesn't work + # in non-interactive mode for some bug. + server.vm.provision "shell", inline: <<-SHELL + parted /dev/sda ---pretend-input-tty < fzf#install() } } +Plug 'junegunn/fzf.vim' +let g:fzf_command_prefix = 'Fzf' + +" Unmanaged plugin (manually installed and updated) +"Plug '~/my-prototype-plugin' + +Plug 'tpope/vim-sensible' +Plug 'tpope/vim-surround' +Plug 'tpope/vim-fugitive' +Plug 'thinca/vim-quickrun' +Plug 'ctrlpvim/ctrlp.vim' +Plug 'flazz/vim-colorschemes' +Plug 'thinca/vim-quickrun' + +Plug 'jpo/vim-railscasts-theme' +Plug 'godlygeek/tabular' +Plug 'plasticboy/vim-markdown' +let g:vim_markdown_folding_disabled = 1 + +Plug 'dense-analysis/ale' + +Plug 'vim-scripts/taglist.vim' +let Tlist_Use_Right_Window = 1 + +Plug 'prabirshrestha/async.vim' +Plug 'prabirshrestha/vim-lsp' +Plug 'prabirshrestha/asyncomplete.vim' +Plug 'prabirshrestha/asyncomplete-lsp.vim' +Plug 'natebosch/vim-lsc' +Plug 'thomasfaingnaert/vim-lsp-snippets' +Plug 'thomasfaingnaert/vim-lsp-ultisnips' +let g:lsp_async_completion = 1 + +Plug 'tyru/current-func-info.vim' +Plug 'yasufum/vim-os-unittestr' + +" Initialize plugin system +call plug#end() + +syntax on +set number +set relativenumber +set shiftwidth=4 +set tabstop=4 +set expandtab +set showcmd +set showmatch +set hlsearch +set laststatus=2 +set encoding=utf-8 +set fileencoding=utf-8 +set termencoding=utf-8 +set autoindent +set scrolloff=4 +set smartcase +set textwidth=80 +set colorcolumn=+1 + +set visualbell t_vb= +set noerrorbells + +set path+=** +set wildmenu + +colorscheme delek +"colorscheme railscasts + +autocmd FileType python set textwidth=79 +autocmd FileType gitcommit set textwidth=72 + +nnoremap ; +nnoremap :NERDTreeToggle +" enable line numbers +let NERDTreeShowLineNumbers=1 +" make sure relative line number is used +autocmd FileType nerdtree setlocal relativenumber + +""" Open vimrc from ':Conf' command. +function! s:open_vimrc() abort + new ~/.vimrc +endfunction +command! Conf call s:open_vimrc() + +function! s:configure_lsp() abort + setlocal omnifunc=lsp#complete + nnoremap :LspDefinition + nnoremap :LspHover + "nnoremap + nnoremap d :LspDefinition + nnoremap r :LspReferences + nnoremap t :LspTypeDefinition + nnoremap s :LspDocumentSymbol + nnoremap S :LspWorkspaceSymbol + nnoremap f :LspDocumentFormat + vnoremap f :LspDocumentRangeFormat + nnoremap h :LspHover + nnoremap i :LspImplementation + nnoremap e :LspNextError + nnoremap E :LspPreviousError + nnoremap N :LspRename +endfunction + +" Do ALE diagnostic +let g:lsp_diagnostics_enabled = 0 + +if executable('pyls') + autocmd User lsp_setup call lsp#register_server({ + \ 'name': 'pyls', + \ 'cmd': { server_info -> ['pyls'] }, + \ 'whitelist': ['python'], + \ 'workspace_config': {'pyls': {'plugins': { + \ 'pycodestyle': {'enabled': v:false}, + \ 'jedi_definition': {'follow_imports': v:true, 'follow_builtin_imports': v:true},}}} + \}) + "autocmd BufWritePre *.py LspDocumentFormatSync + autocmd FileType python call s:configure_lsp() +endif + +if executable('bash-language-server') + au User lsp_setup call lsp#register_server({ + \ 'name': 'bash-language-server', + \ 'cmd': {server_info->[&shell, &shellcmdflag, 'bash-language-server start']}, + \ 'whitelist': ['sh'], + \ }) + "autocmd BufWritePre *.sh LspDocumentFormatSync + autocmd FileType sh call s:configure_lsp() +endif diff --git a/vagrant/devstack/samples/machines-2nodes.yml b/vagrant/devstack/samples/machines-2nodes.yml index ca9a2a8e8..cbbb5d91c 100644 --- a/vagrant/devstack/samples/machines-2nodes.yml +++ b/vagrant/devstack/samples/machines-2nodes.yml @@ -1,15 +1,16 @@ global: - # (optional) Path of your SSH public key. Default is "~/.ssh/id_rsa.pub". - #ssh_pub_key: "~/.ssh/id_rsa.pub" + # (optional) Path of your SSH public key. Default is "~/.ssh/id_ed25519.pub". + #ssh_pub_key: "~/.ssh/id_ed25519.pub" machines: - hostname: controller provider: virtualbox - box: ubuntu/focal64 + # Refer to the supported boxes in "Requirements" section in README.md + box: bento/ubuntu-22.04 nof_cpus: 4 mem_size: 12 - disk_size: 50 + disk_size: 160 private_ips: - 192.168.56.11 public_ips: @@ -19,10 +20,10 @@ machines: - hostname: compute provider: virtualbox - box: ubuntu/focal64 + box: bento/ubuntu-22.04 nof_cpus: 4 mem_size: 8 - disk_size: 50 + disk_size: 160 private_ips: - 192.168.56.12 public_ips: diff --git a/vagrant/devstack/samples/machines.yml b/vagrant/devstack/samples/machines.yml index 16ec9ba42..1f8e37472 100644 --- a/vagrant/devstack/samples/machines.yml +++ b/vagrant/devstack/samples/machines.yml @@ -1,16 +1,16 @@ global: - # (optional) Path of your SSH public key. Default is "~/.ssh/id_rsa.pub". - #ssh_pub_key: "~/.ssh/id_rsa.pub" + # (optional) Path of your SSH public key. Default is "~/.ssh/id_ed25519.pub". + #ssh_pub_key: "~/.ssh/id_ed25519.pub" machines: - hostname: controller provider: virtualbox - # Supported boxes are `ubuntu/focal64`, `centos/stream8`. - box: ubuntu/focal64 + # Refer to the supported boxes in "Requirements" section in README.md + box: bento/ubuntu-22.04 nof_cpus: 4 mem_size: 12 - disk_size: 50 + disk_size: 160 private_ips: - 192.168.56.11 public_ips: diff --git a/vagrant/devstack/site.yaml b/vagrant/devstack/site.yaml index ce386bc60..875f521da 100644 --- a/vagrant/devstack/site.yaml +++ b/vagrant/devstack/site.yaml @@ -1,4 +1,16 @@ --- +- name: ubuntu-jammy controller node + hosts: ubuntu-jammy.controller + remote_user: stack + roles: + - ubuntu-jammy/controller + +- name: ubuntu-jammy compute nodes + hosts: ubuntu-jammy.compute + remote_user: stack + roles: + - ubuntu-jammy/compute + - name: ubuntu-focal controller node hosts: ubuntu-focal.controller remote_user: stack