github.com/joelanford/operator-sdk@v0.8.2/internal/pkg/scaffold/ansible/dockerfilehybrid.go (about) 1 // Copyright 2019 The Operator-SDK Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package ansible 16 17 import ( 18 "path/filepath" 19 20 "github.com/operator-framework/operator-sdk/internal/pkg/scaffold" 21 "github.com/operator-framework/operator-sdk/internal/pkg/scaffold/input" 22 ) 23 24 //DockerfileHybrid - Dockerfile for a hybrid operator 25 type DockerfileHybrid struct { 26 input.Input 27 28 // Playbook - if true, include a COPY statement for playbook.yml 29 Playbook bool 30 31 // Roles - if true, include a COPY statement for the roles directory 32 Roles bool 33 34 // Watches - if true, include a COPY statement for watches.yaml 35 Watches bool 36 } 37 38 // GetInput - gets the input 39 func (d *DockerfileHybrid) GetInput() (input.Input, error) { 40 if d.Path == "" { 41 d.Path = filepath.Join(scaffold.BuildDir, scaffold.DockerfileFile) 42 } 43 d.TemplateBody = dockerFileHybridAnsibleTmpl 44 d.Delims = AnsibleDelims 45 return d.Input, nil 46 } 47 48 const dockerFileHybridAnsibleTmpl = `FROM ansible/ansible-runner:1.2 49 50 RUN yum remove -y ansible python-idna 51 RUN yum install -y inotify-tools && yum clean all 52 RUN pip uninstall ansible-runner -y 53 54 RUN pip install --upgrade setuptools==41.0.1 55 RUN pip install "urllib3>=1.23,<1.25" 56 RUN pip install ansible==2.7.10 \ 57 ansible-runner==1.2 \ 58 ansible-runner-http==1.0.0 \ 59 idna==2.7 \ 60 "kubernetes>=8.0.0,<9.0.0" \ 61 openshift==0.8.8 62 63 RUN mkdir -p /etc/ansible \ 64 && echo "localhost ansible_connection=local" > /etc/ansible/hosts \ 65 && echo '[defaults]' > /etc/ansible/ansible.cfg \ 66 && echo 'roles_path = /opt/ansible/roles' >> /etc/ansible/ansible.cfg \ 67 && echo 'library = /usr/share/ansible/openshift' >> /etc/ansible/ansible.cfg 68 69 ENV OPERATOR=/usr/local/bin/ansible-operator \ 70 USER_UID=1001 \ 71 USER_NAME=ansible-operator\ 72 HOME=/opt/ansible 73 74 [[- if .Watches ]] 75 COPY watches.yaml ${HOME}/watches.yaml[[ end ]] 76 77 # install operator binary 78 COPY build/_output/bin/[[.ProjectName]] ${OPERATOR} 79 # install k8s_status Ansible Module 80 COPY library/k8s_status.py /usr/share/ansible/openshift/ 81 82 COPY bin /usr/local/bin 83 RUN /usr/local/bin/user_setup 84 85 [[- if .Roles ]] 86 COPY roles/ ${HOME}/roles/[[ end ]] 87 [[- if .Playbook ]] 88 COPY playbook.yml ${HOME}/playbook.yml[[ end ]] 89 90 ENTRYPOINT ["/usr/local/bin/entrypoint"] 91 92 USER ${USER_UID} 93 `