Wolfgang Kulhanek
2020-03-11 d15b2fac7063fc91e62bcc3a4e4b61b0f14e925e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
---
- name: Install packages for OpenStack CLI
  package:
    name:
    - gcc
    - python3
    - python3-devel
 
- name: Copy requirements.txt
  copy:
    src: "./files/openstack_requirements.txt"
    dest: "/root/requirements.txt"
 
- name: Install python requirements for OpenStack CLI
  command: "pip3 install -r /root/requirements.txt"
 
- name: Remove requirements.txt
  file:
    path: "/root/requirements.txt"
    state: absent
 
- name: Add /usr/local/bin to PATH
  copy:
    dest: /etc/profile.d/custom-path.sh
    content: 'PATH=$PATH:/usr/local/bin'
 
- name: Create .config directory
  file:
    path: /home/{{ ansible_user }}/.config/openstack
    state: directory
    owner: "{{ ansible_user }}"
    group: users
    mode: 0744
 
- name: Create clouds.yaml file
  template:
    src: "clouds.yaml.j2"
    dest: "/home/{{ ansible_user }}/.config/openstack/clouds.yaml"
    owner: "{{ ansible_user }}"
    mode: 0700
 
- name: Add environment variables for API and Ingress FIPs
  lineinfile:
    path: "/home/{{ ansible_user }}/.bashrc"
    regexp: "^export {{ item.env_var }}"
    line: "export {{ item.env_var }}={{ item.ip }}"
  loop:
    - ip: "{{ hostvars['localhost']['ocp_api_fip'] }}"
      env_var: "API_FIP"
    - ip: "{{ hostvars['localhost']['ocp_ingress_fip'] }}"
      env_var: "INGRESS_FIP"
  loop_control:
    label: item.ip
  when: openshift_fip_provision
 
- name: Add environment variable for DNS domain
  lineinfile:
    path: "/home/{{ ansible_user }}/.bashrc"
    regexp: "^export OPENSHIFT_DNS_ZONE"
    line: "export OPENSHIFT_DNS_ZONE={{ osp_cluster_dns_zone }}"
  when: openshift_fip_provision
 
- name: Add environment variable for OpenStack credentials
  lineinfile:
    path: "/home/{{ ansible_user }}/.bashrc"
    regexp: "^export OS_CLOUD"
    line: "export OS_CLOUD={{ osp_cloud_name }}"
 
- name: Create resources directory
  file:
    path: "/home/{{ ansible_user }}/resources"
    state: directory
    owner: "{{ ansible_user }}"
    group: users
    mode: 0744
 
- name: Set OpenStack Object Store Account
  when: ocp4_installer_version is version_compare('4.4.0', '<')
  command: >-
    openstack --os-cloud={{ osp_cloud_name }} object store account set
    --property Temp-URL-Key=somename
  become: no