Fuel is the control plane for installing and managing OpenStack. It is capable of doing bare metal provisioning of physical nodes, installing OpenStack on them, and much more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sandbox.mk 9.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. .PHONY: show-ubuntu-sandbox-repos show-centos-sandbox-repos
  2. define yum_local_repo
  3. [upstream-local-mirror]
  4. name=Local upstream mirror
  5. baseurl=file:///mirrors/centos/os/x86_64
  6. gpgcheck=0
  7. enabled=1
  8. priority=10
  9. endef
  10. define yum_local_mos_repo
  11. [mos-local-mirror]
  12. name=Local mirror
  13. baseurl=file:///mirrors/mos-centos
  14. gpgcheck=0
  15. enabled=1
  16. priority=10
  17. endef
  18. define yum_upstream_repo
  19. [upstream]
  20. name=Upstream mirror
  21. baseurl=$(SANDBOX_MIRROR_CENTOS_UPSTREAM)/os/$(CENTOS_ARCH)/
  22. gpgcheck=0
  23. priority=1
  24. sslverify=False
  25. [upstream-updates]
  26. name=Upstream mirror
  27. baseurl=$(SANDBOX_MIRROR_CENTOS_UPSTREAM)/updates/$(CENTOS_ARCH)/
  28. gpgcheck=0
  29. priority=1
  30. sslverify=False
  31. endef
  32. define yum_epel_repo
  33. [epel]
  34. name=epel mirror
  35. baseurl=$(SANDBOX_MIRROR_EPEL)/$(CENTOS_MAJOR)/$(CENTOS_ARCH)/
  36. gpgcheck=0
  37. priority=3
  38. endef
  39. define sandbox_yum_conf
  40. [main]
  41. cachedir=/tmp/cache
  42. keepcache=0
  43. debuglevel=2
  44. logfile=/tmp/yum.log
  45. exclude=*.i686.rpm
  46. exactarch=1
  47. obsoletes=1
  48. gpgcheck=0
  49. plugins=1
  50. pluginpath=/etc/yum-plugins
  51. pluginconfpath=/etc/yum/pluginconf.d
  52. reposdir=/etc/yum.repos.d
  53. sslverify=False
  54. endef
  55. define external_sandbox_yum_conf
  56. [main]
  57. cachedir=$(SANDBOX)/cache
  58. keepcache=0
  59. debuglevel=2
  60. logfile=$(SANDBOX)/yum.log
  61. exclude=*.i686.rpm
  62. exactarch=1
  63. obsoletes=1
  64. gpgcheck=0
  65. plugins=1
  66. pluginpath=$(SANDBOX)/etc/yum-plugins
  67. pluginconfpath=$(SANDBOX)/etc/yum/pluginconf.d
  68. reposdir=$(SANDBOX)/etc/yum.repos.d
  69. sslverify=False
  70. endef
  71. SANDBOX_PACKAGES:=bash yum
  72. define SANDBOX_UP
  73. echo "Starting SANDBOX up"
  74. mkdir -p $(SANDBOX)/etc/yum.repos.d
  75. cat > $(SANDBOX)/etc/yum.conf <<EOF
  76. $(sandbox_yum_conf)
  77. EOF
  78. # this conf is used outside chroot in order to install yum
  79. cat > $(SANDBOX)/etc/external.yum.conf <<EOF
  80. $(external_sandbox_yum_conf)
  81. EOF
  82. cp /etc/resolv.conf $(SANDBOX)/etc/resolv.conf
  83. cp /etc/hosts $(SANDBOX)/etc/hosts
  84. cat > $(SANDBOX)/etc/yum.repos.d/base.repo <<EOF
  85. $(yum_upstream_repo)
  86. $(yum_epel_repo)
  87. EOF
  88. mkdir -p $(SANDBOX)/etc/yum/pluginconf.d/
  89. mkdir -p $(SANDBOX)/etc/yum-plugins/
  90. mkdir -p $(SANDBOX)/mirrors
  91. cp $(SOURCE_DIR)/mirror/centos/yum-priorities-plugin.py $(SANDBOX)/etc/yum-plugins/priorities.py
  92. cat > $(SANDBOX)/etc/yum/pluginconf.d/priorities.conf << EOF
  93. [main]
  94. enabled=1
  95. check_obsoletes=1
  96. full_match=1
  97. EOF
  98. sudo rpm -i --root=$(SANDBOX) `find $(LOCAL_MIRROR_CENTOS_OS_BASEURL) -name "centos-release*rpm" | head -1` || \
  99. echo "centos-release already installed"
  100. sudo rm -vf $(SANDBOX)/etc/yum.repos.d/Cent*
  101. sudo /bin/sh -c 'export TMPDIR=$(SANDBOX)/tmp/yum TMP=$(SANDBOX)/tmp/yum; yum -c $(SANDBOX)/etc/external.yum.conf --installroot=$(SANDBOX) -y --nogpgcheck install yum'
  102. echo 'Rebuilding RPM DB'
  103. sudo rpm --root=$(SANDBOX) --rebuilddb
  104. echo 'Installing packages for Sandbox'
  105. mount | grep -q $(SANDBOX)/mirrors || sudo mount --bind $(LOCAL_MIRROR) $(SANDBOX)/mirrors
  106. mount | grep -q $(SANDBOX)/proc || sudo mount --bind /proc $(SANDBOX)/proc
  107. mount | grep -q $(SANDBOX)/dev || sudo mount --bind /dev $(SANDBOX)/dev
  108. # after installing yum, let's add MOS repos from mounted /mirrors
  109. cat > $(SANDBOX)/etc/yum.repos.d/base.repo <<EOF
  110. $(yum_upstream_repo)
  111. $(yum_epel_repo)
  112. $(yum_local_repo)
  113. $(yum_local_mos_repo)
  114. EOF
  115. echo $(SANDBOX_PACKAGES) | xargs -n1 | xargs -I_package sudo sh -c 'rm -vf $(SANDBOX)/etc/yum.repos.d/Cent*; chroot $(SANDBOX) yum -y --nogpgcheck install _package'
  116. # clean all repos except the MOS + upsream + our epel
  117. sudo rm -vf $(SANDBOX)/etc/yum.repos.d/epel*
  118. sudo rm -vf $(SANDBOX)/etc/yum.repos.d/Cent*
  119. endef
  120. define SANDBOX_DOWN
  121. sudo umount $(SANDBOX)/proc || true
  122. sudo umount $(SANDBOX)/dev || true
  123. sudo umount $(SANDBOX)/mirrors || true
  124. endef
  125. define apt_sources_list
  126. #Upstream Ubuntu mirrors
  127. deb $(MIRROR_UBUNTU_METHOD)://$(MIRROR_UBUNTU)$(MIRROR_UBUNTU_ROOT) $(MIRROR_UBUNTU_SUITE) $(MIRROR_UBUNTU_SECTION)
  128. deb $(MIRROR_UBUNTU_METHOD)://$(MIRROR_UBUNTU)$(MIRROR_UBUNTU_ROOT) $(MIRROR_UBUNTU_SUITE)-updates $(MIRROR_UBUNTU_SECTION)
  129. deb $(MIRROR_UBUNTU_METHOD)://$(MIRROR_UBUNTU)$(MIRROR_UBUNTU_ROOT) $(MIRROR_UBUNTU_SUITE)-security $(MIRROR_UBUNTU_SECTION)
  130. # MOS repos
  131. deb $(MIRROR_MOS_UBUNTU_METHOD)://$(MIRROR_MOS_UBUNTU)$(MIRROR_MOS_UBUNTU_ROOT) $(MIRROR_MOS_UBUNTU_SUITE) $(MIRROR_MOS_UBUNTU_SECTION)
  132. deb $(MIRROR_MOS_UBUNTU_METHOD)://$(MIRROR_MOS_UBUNTU)$(MIRROR_MOS_UBUNTU_ROOT) $(MIRROR_MOS_UBUNTU_SUITE)-security $(MIRROR_MOS_UBUNTU_SECTION)
  133. deb $(MIRROR_MOS_UBUNTU_METHOD)://$(MIRROR_MOS_UBUNTU)$(MIRROR_MOS_UBUNTU_ROOT) $(MIRROR_MOS_UBUNTU_SUITE)-proposed $(MIRROR_MOS_UBUNTU_SECTION)
  134. deb $(MIRROR_MOS_UBUNTU_METHOD)://$(MIRROR_MOS_UBUNTU)$(MIRROR_MOS_UBUNTU_ROOT) $(MIRROR_MOS_UBUNTU_SUITE)-updates $(MIRROR_MOS_UBUNTU_SECTION)
  135. deb $(MIRROR_MOS_UBUNTU_METHOD)://$(MIRROR_MOS_UBUNTU)$(MIRROR_MOS_UBUNTU_ROOT) $(MIRROR_MOS_UBUNTU_SUITE)-holdback $(MIRROR_MOS_UBUNTU_SECTION)
  136. #Extra repositories
  137. $(if $(EXTRA_DEB_REPOS),$(subst |,$(newline)deb ,deb $(EXTRA_DEB_REPOS)))
  138. endef
  139. define apt_preferences
  140. # Apt repo @ obs-1 has Codename=trusty (which is OK)
  141. # However the one @ mirror.fuel-infra has Codename=mos6.1
  142. Package: *
  143. Pin: release o=Mirantis, n=$(MIRROR_UBUNTU_SUITE)
  144. Pin-Priority: 1101
  145. Package: *
  146. Pin: release o=Mirantis, n=$(PRODUCT_NAME)$(PRODUCT_VERSION)
  147. Pin-Priority: 1101
  148. # to install packages from unmerged fuel-infra requests
  149. Package: *
  150. Pin: release l=$(UBUNTU_RELEASE)-fuel-$(PRODUCT_VERSION)-stable*
  151. Pin-Priority: 1101
  152. Package: *
  153. Pin: release o=Open Build Service $(UBUNTU_RELEASE)-fuel-$(PRODUCT_VERSION)-stable*
  154. Pin-Priority: 1101
  155. endef
  156. define SANDBOX_UBUNTU_UP
  157. set -e
  158. echo "SANDBOX_UBUNTU_UP: start"
  159. mkdir -p $(SANDBOX_UBUNTU)
  160. mkdir -p $(SANDBOX_UBUNTU)/usr/sbin
  161. cat > $(BUILD_DIR)/policy-rc.d << EOF
  162. #!/bin/sh
  163. # suppress services start in the staging chroots
  164. exit 101
  165. EOF
  166. chmod 755 $(BUILD_DIR)/policy-rc.d
  167. mkdir -p $(SANDBOX_UBUNTU)/etc/init.d
  168. touch $(SANDBOX_UBUNTU)/etc/init.d/.legacy-bootordering
  169. mkdir -p $(SANDBOX_UBUNTU)/usr/sbin
  170. cp -a $(BUILD_DIR)/policy-rc.d $(SANDBOX_UBUNTU)/usr/sbin
  171. echo "Running debootstrap"
  172. sudo debootstrap --no-check-gpg --include=ca-certificates --arch=$(UBUNTU_ARCH) $(MIRROR_UBUNTU_SUITE) $(SANDBOX_UBUNTU) $(MIRROR_UBUNTU_METHOD)://$(MIRROR_UBUNTU)$(MIRROR_UBUNTU_ROOT)
  173. if [ -e $(SANDBOX_UBUNTU)/etc/resolv.conf ]; then sudo cp -a $(SANDBOX_UBUNTU)/etc/resolv.conf $(SANDBOX_UBUNTU)/etc/resolv.conf.orig; fi
  174. sudo cp /etc/resolv.conf $(SANDBOX_UBUNTU)/etc/resolv.conf
  175. if [ -e $(SANDBOX_UBUNTU)/etc/hosts ]; then sudo cp -a $(SANDBOX_UBUNTU)/etc/hosts $(SANDBOX_UBUNTU)/etc/hosts.orig; fi
  176. sudo cp /etc/hosts $(SANDBOX_UBUNTU)/etc/hosts
  177. echo "Generating utf8 locale"
  178. sudo chroot $(SANDBOX_UBUNTU) /usr/bin/env -i \
  179. LC_ALL=C \
  180. DEBIAN_FRONTEND=noninteractive \
  181. DEBCONF_NONINTERACTIVE_SEEN=true \
  182. /bin/sh -c 'locale-gen en_US.UTF-8; dpkg-reconfigure locales'
  183. echo "Preparing directory for chroot local mirror"
  184. sudo mkdir -p $(SANDBOX_UBUNTU)/etc/apt/preferences.d/
  185. echo "Generating pinning file for Ubuntu SandBox"
  186. cat > $(BUILD_DIR)/mirror/ubuntu/preferences << EOF
  187. $(apt_preferences)
  188. EOF
  189. sudo cp $(BUILD_DIR)/mirror/ubuntu/preferences $(SANDBOX_UBUNTU)/etc/apt/preferences.d/
  190. echo "Configuring apt sources.list"
  191. cat > $(BUILD_DIR)/mirror/ubuntu/sources.list << EOF
  192. $(apt_sources_list)
  193. EOF
  194. sudo cp $(BUILD_DIR)/mirror/ubuntu/sources.list $(SANDBOX_UBUNTU)/etc/apt/
  195. sudo cp $(BUILD_DIR)/policy-rc.d $(SANDBOX_UBUNTU)/usr/sbin
  196. echo "Allowing using unsigned repos"
  197. echo "APT::Get::AllowUnauthenticated 1;" | sudo tee $(SANDBOX_UBUNTU)/etc/apt/apt.conf.d/02mirantis-unauthenticated
  198. if [ "$(SANDBOX_COPY_CERTS)" = "1" ] ; then
  199. echo "Copying local certificates and CA to chroot"
  200. sudo bash -c "mkdir -p $(SANDBOX_UBUNTU)/usr/share/ca-certificates/ ; rsync -arzL /etc/ssl/certs/ $(SANDBOX_UBUNTU)/usr/share/ca-certificates/local/"
  201. echo "Acquire::https { Verify-Peer \"true\"; Verify-Host \"true\"; }; " | sudo tee -a $(SANDBOX_UBUNTU)/etc/apt/apt.conf.d/05-local-ssl-certs
  202. sudo chroot $(SANDBOX_UBUNTU) sh -xc "(cd /usr/share/ca-certificates; find local -type f) >> /etc/ca-certificates.conf"
  203. sudo chroot $(SANDBOX_UBUNTU) update-ca-certificates
  204. fi
  205. echo "Updating apt package database"
  206. sudo chroot $(SANDBOX_UBUNTU) bash -c "(mkdir -p /tmp/user/0)"
  207. sudo chroot $(SANDBOX_UBUNTU) apt-get update
  208. if ! mountpoint -q $(SANDBOX_UBUNTU)/proc; then sudo mount -t proc sandboxproc $(SANDBOX_UBUNTU)/proc; fi
  209. echo "Installing additional packages: $(SANDBOX_DEB_PKGS)"
  210. sudo chroot $(SANDBOX_UBUNTU) env LC_ALL=C DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true apt-get dist-upgrade --yes
  211. test -n "$(SANDBOX_DEB_PKGS)" && sudo chroot $(SANDBOX_UBUNTU) env LC_ALL=C DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true apt-get install --yes $(SANDBOX_DEB_PKGS)
  212. echo "SANDBOX_UBUNTU_UP: done"
  213. endef
  214. define SANDBOX_UBUNTU_DOWN
  215. if mountpoint -q $(SANDBOX_UBUNTU)/proc; then sudo umount $(SANDBOX_UBUNTU)/proc; fi
  216. sudo umount $(SANDBOX_UBUNTU)/tmp/apt || true
  217. endef
  218. show-ubuntu-sandbox-repos: export apt_source_content:=$(apt_sources_list)
  219. show-ubuntu-sandbox-repos: export apt_pinning_content:=$(apt_preferences)
  220. show-ubuntu-sandbox-repos:
  221. /bin/echo -e "$${apt_source_content}"
  222. /bin/echo -e "$${apt_pinning_content}"
  223. show-centos-sandbox-repos: export sandbox_yum_conf_content:=$(sandbox_yum_conf)
  224. show-centos-sandbox-repos: export yum_upstream_repo_content:=$(yum_upstream_repo)
  225. show-centos-sandbox-repos: export yum_epel_repo_content:=$(yum_epel_repo)
  226. show-centos-sandbox-repos: export yum_local_repo_content:=$(yum_local_repo)
  227. show-centos-sandbox-repos: export yum_local_mos_repo_content:=$(yum_local_mos_repo)
  228. show-centos-sandbox-repos:
  229. /bin/echo -e "$${sandbox_yum_conf_content}\n"
  230. /bin/echo -e "$${yum_upstream_repo_content}\n"
  231. /bin/echo -e "$${yum_epel_repo_content}\n"
  232. /bin/echo -e "$${yum_local_repo_content}\n"
  233. /bin/echo -e "$${yum_local_mos_repo_content}\n"