-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #316 from freyes/configure-juju-role
Convert playbook to configure juju into a role.
- Loading branch information
Showing
4 changed files
with
107 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,106 +1,3 @@ | ||
- hosts: all | ||
tasks: | ||
- name: hack around juju's reluctance to deploy misnamed directories | ||
copy: | ||
src: "/home/ubuntu/{{ zuul.project.src_dir }}/" | ||
dest: "/home/ubuntu/{{ zuul.project.src_dir | replace('charm-', '') }}" | ||
remote_src: yes | ||
# NOTE(freyes): fixes the error below when running `juju` in a fresh | ||
# environment. | ||
# ERROR cannot create juju home directory: mkdir /home/ubuntu/.local/share: permission denied | ||
# WARNING Installing Juju in a strictly confined Snap. To ensure correct operation, create the ~/.local/share/juju directory manually. | ||
- name: Create ~/.local/share/juju directory to run Juju snap in strict mode | ||
ansible.builtin.file: | ||
path: /home/ubuntu/.local/share/juju | ||
state: directory | ||
owner: ubuntu | ||
group: ubuntu | ||
mode: '0700' | ||
- name: 'install crashdump' | ||
become: true | ||
snap: | ||
name: juju-crashdump | ||
classic: yes | ||
register: result | ||
until: result is not failed | ||
retries: 10 | ||
delay: 10 | ||
# Setup Juju | ||
- name: 'install juju' | ||
become: true | ||
snap: | ||
name: juju | ||
# NOTE(freyes): Juju's '2.9' snap track publishes a snap with the | ||
# classic confinement, while juju>=3.1 uses a strict confinement, | ||
# instead of asking users to understand this, we encapsulate this | ||
# information into this inline-if where if the juju_snap_channel has the | ||
# '2.9/' prefix the classic field is set to True, otherwise False. | ||
classic: "{{ juju_snap_channel is defined and juju_snap_channel.startswith('2.9/') }}" | ||
channel: "{{ juju_snap_channel }}" | ||
register: result | ||
until: result is not failed | ||
retries: 10 | ||
delay: 10 | ||
- name: Install libpq-dev | ||
become: true | ||
apt: | ||
name: libpq-dev | ||
- name: Install libmysqlclient-dev | ||
become: true | ||
apt: | ||
name: libmysqlclient-dev | ||
- name: Install libxml2-dev | ||
become: true | ||
apt: | ||
name: libxml2-dev | ||
- name: Install libxslt1-dev | ||
become: true | ||
apt: | ||
name: libxslt1-dev | ||
- name: Install qemu-utils | ||
become: true | ||
apt: | ||
name: qemu-utils | ||
- name: Render juju clouds.yaml | ||
template: | ||
src: clouds.yaml.j2 | ||
dest: clouds.yaml | ||
- name: Add cloud | ||
command: /snap/bin/juju add-cloud --client {{ serverstack_cloud.region_name }} clouds.yaml | ||
- name: 'render credentials.yaml' | ||
template: | ||
src: credentials.yaml.j2 | ||
dest: credentials.yaml | ||
- name: Add credential | ||
command: /snap/bin/juju add-credential {{ serverstack_cloud.region_name }} --client -f credentials.yaml | ||
- name: Clone charm-test-infra | ||
command: git clone https://github.com/openstack-charmers/charm-test-infra /home/ubuntu/charm-test-infra | ||
- name: 'Bootstrap Controller' | ||
command: | | ||
/snap/bin/juju bootstrap \ | ||
--bootstrap-constraints="virt-type=kvm cores=4 mem=8G" \ | ||
--constraints=virt-type=kvm \ | ||
--auto-upgrade=false \ | ||
--model-default=/home/ubuntu/charm-test-infra/juju-configs/model-default-serverstack.yaml \ | ||
--config=/home/ubuntu/charm-test-infra/juju-configs/controller-default.yaml \ | ||
{{ serverstack_cloud.region_name }}/{{ serverstack_cloud.region_name }} | ||
- name: 'Configure cloudinit-userdata model-default' | ||
shell: | ||
cmd: | | ||
cat > /home/ubuntu/cloudinit-userdata.yaml << EOF | ||
cloudinit-userdata: | | ||
apt: | ||
conf: | | ||
APT { | ||
Get { | ||
Always-Include-Phased-Updates 'true'; | ||
} | ||
} | ||
preruncmd: | ||
- sed -i "/^ExecStart.*systemd-resolved/a Environment=SYSTEMD_LOG_LEVEL=debug" /lib/systemd/system/systemd-resolved.service | ||
- systemctl daemon-reload | ||
- systemctl restart systemd-resolved | ||
EOF | ||
/snap/bin/juju model-default /home/ubuntu/cloudinit-userdata.yaml | ||
args: | ||
executable: /bin/bash | ||
roles: | ||
- juju-setup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
juju_snap_channel: "2.9/stable" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
- name: hack around juju's reluctance to deploy misnamed directories | ||
copy: | ||
src: "/home/ubuntu/{{ zuul.project.src_dir }}/" | ||
dest: "/home/ubuntu/{{ zuul.project.src_dir | replace('charm-', '') }}" | ||
remote_src: yes | ||
# NOTE(freyes): fixes the error below when running `juju` in a fresh | ||
# environment. | ||
# ERROR cannot create juju home directory: mkdir /home/ubuntu/.local/share: permission denied | ||
# WARNING Installing Juju in a strictly confined Snap. To ensure correct operation, create the ~/.local/share/juju directory manually. | ||
- name: Create ~/.local/share/juju directory to run Juju snap in strict mode | ||
ansible.builtin.file: | ||
path: /home/ubuntu/.local/share/juju | ||
state: directory | ||
owner: ubuntu | ||
group: ubuntu | ||
mode: '0700' | ||
- name: 'install crashdump' | ||
become: true | ||
snap: | ||
name: juju-crashdump | ||
classic: yes | ||
register: result | ||
until: result is not failed | ||
retries: 10 | ||
delay: 10 | ||
# Setup Juju | ||
- name: 'install juju' | ||
become: true | ||
snap: | ||
name: juju | ||
# NOTE(freyes): Juju's '2.9' snap track publishes a snap with the | ||
# classic confinement, while juju>=3.1 uses a strict confinement, | ||
# instead of asking users to understand this, we encapsulate this | ||
# information into this inline-if where if the juju_snap_channel has the | ||
# '2.9/' prefix the classic field is set to True, otherwise False. | ||
classic: "{{ juju_snap_channel is defined and juju_snap_channel.startswith('2.9/') }}" | ||
channel: "{{ juju_snap_channel }}" | ||
register: result | ||
until: result is not failed | ||
retries: 10 | ||
delay: 10 | ||
- name: Install libpq-dev | ||
become: true | ||
apt: | ||
name: libpq-dev | ||
- name: Install libmysqlclient-dev | ||
become: true | ||
apt: | ||
name: libmysqlclient-dev | ||
- name: Install libxml2-dev | ||
become: true | ||
apt: | ||
name: libxml2-dev | ||
- name: Install libxslt1-dev | ||
become: true | ||
apt: | ||
name: libxslt1-dev | ||
- name: Install qemu-utils | ||
become: true | ||
apt: | ||
name: qemu-utils | ||
- name: Render juju clouds.yaml | ||
template: | ||
src: clouds.yaml.j2 | ||
dest: clouds.yaml | ||
- name: Add cloud | ||
command: /snap/bin/juju add-cloud --client {{ serverstack_cloud.region_name }} clouds.yaml | ||
- name: 'render credentials.yaml' | ||
template: | ||
src: credentials.yaml.j2 | ||
dest: credentials.yaml | ||
- name: Add credential | ||
command: /snap/bin/juju add-credential {{ serverstack_cloud.region_name }} --client -f credentials.yaml | ||
- name: Clone charm-test-infra | ||
command: git clone https://github.com/openstack-charmers/charm-test-infra /home/ubuntu/charm-test-infra | ||
- name: 'Bootstrap Controller' | ||
command: | | ||
/snap/bin/juju bootstrap \ | ||
--bootstrap-constraints="virt-type=kvm cores=4 mem=8G" \ | ||
--constraints=virt-type=kvm \ | ||
--auto-upgrade=false \ | ||
--model-default=/home/ubuntu/charm-test-infra/juju-configs/model-default-serverstack.yaml \ | ||
--config=/home/ubuntu/charm-test-infra/juju-configs/controller-default.yaml \ | ||
{{ serverstack_cloud.region_name }}/{{ serverstack_cloud.region_name }} | ||
- name: 'Configure cloudinit-userdata model-default' | ||
shell: | ||
cmd: | | ||
cat > /home/ubuntu/cloudinit-userdata.yaml << EOF | ||
cloudinit-userdata: | | ||
apt: | ||
conf: | | ||
APT { | ||
Get { | ||
Always-Include-Phased-Updates 'true'; | ||
} | ||
} | ||
preruncmd: | ||
- sed -i "/^ExecStart.*systemd-resolved/a Environment=SYSTEMD_LOG_LEVEL=debug" /lib/systemd/system/systemd-resolved.service | ||
- systemctl daemon-reload | ||
- systemctl restart systemd-resolved | ||
EOF | ||
/snap/bin/juju model-default /home/ubuntu/cloudinit-userdata.yaml | ||
args: | ||
executable: /bin/bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters